Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevTools: Props editing interface tweaks #16740

Merged
merged 3 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import {useEditableValue} from '../hooks';
type OverrideValueFn = (path: Array<string | number>, value: any) => void;

type EditableValueProps = {|
className?: string,
dataType: string,
initialValue: any,
overrideValueFn: OverrideValueFn,
path: Array<string | number>,
|};

export default function EditableValue({
className = '',
dataType,
initialValue,
overrideValueFn,
Expand Down Expand Up @@ -74,7 +76,7 @@ export default function EditableValue({
<Fragment>
<input
autoComplete="new-password"
className={isValid ? styles.Input : styles.Invalid}
className={`${isValid ? styles.Input : styles.Invalid} ${className}`}
onChange={handleChange}
onKeyDown={handleKeyDown}
placeholder={placeholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@
display: flex;
align-items: center;
}

.EditableValue {
min-width: 1rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function InspectedElementTree({
</Button>
)}
</div>
{isEmpty && <div className={styles.Empty}>None</div>}
{isEmpty && !canAddEntries && <div className={styles.Empty}>None</div>}
{!isEmpty &&
(entries: any).map(([name, value]) => (
<KeyValue
Expand All @@ -104,6 +104,7 @@ export default function InspectedElementTree({
/>
:&nbsp;
<EditableValue
className={styles.EditableValue}
initialValue={''}
overrideValueFn={handleNewEntryValue}
path={[newPropName]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function InspectedElementView({
inspectPath={inspectPropsPath}
overrideValueFn={overridePropsFn}
showWhenEmpty={true}
canAddEntries={true}
canAddEntries={typeof overridePropsFn === 'function'}
/>
{type === ElementTypeSuspense ? (
<InspectedElementTree
Expand Down