Skip to content

Commit bb75a4f

Browse files
author
Brian Vaughn
authored
Improved selection and toggling for props/hooks/state (#17588)
1. Enable nested values to be expanded/collapsed by clicking on values as well as keys. 2. Enable keys and values to be selectable (for copy-pasting purposes)
1 parent 7309c5f commit bb75a4f

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

packages/react-devtools-shared/src/devtools/views/Components/HooksTree.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
.Name,
2828
.NameAnonymous {
2929
flex: 0 0 auto;
30-
user-select: none;
30+
cursor: default;
3131
}
3232
.Name {
3333
color: var(--color-dim);
@@ -39,7 +39,7 @@
3939
.EditableName {
4040
color: var(--color-attribute-name);
4141
flex: 0 0 auto;
42-
user-select: none;
42+
cursor: default;
4343
}
4444
.EditableName:after,
4545
.Name:after {
@@ -52,6 +52,7 @@
5252
color: var(--color-attribute-value);
5353
overflow: hidden;
5454
text-overflow: ellipsis;
55+
cursor: default;
5556
}
5657

5758
.None {

packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ function HookView({canEditHooks, hook, id, inspectPath, path}: HookViewProps) {
208208
{name || 'Anonymous'}
209209
</span>{' '}
210210
{/* $FlowFixMe */}
211-
<span className={styles.Value}>{displayValue}</span>
211+
<span className={styles.Value} onClick={toggleIsOpen}>
212+
{displayValue}
213+
</span>
212214
</div>
213215
<div className={styles.Children} hidden={!isOpen}>
214216
{subHooksView}

packages/react-devtools-shared/src/devtools/views/Components/KeyValue.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
.Name {
66
color: var(--color-dim);
77
flex: 0 0 auto;
8-
user-select: none;
8+
cursor: default;
99
}
1010
.EditableName {
1111
color: var(--color-attribute-name);
1212
flex: 0 0 auto;
13-
user-select: none;
13+
cursor: default;
1414
}
1515
.EditableName:after,
1616
.Name:after {
@@ -24,6 +24,7 @@
2424
white-space: nowrap;
2525
overflow: hidden;
2626
text-overflow: ellipsis;
27+
cursor: default;
2728
}
2829

2930
.None {

packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ export default function KeyValue({
127127
onClick={isInspectable ? toggleIsOpen : undefined}>
128128
{name}
129129
</span>
130-
<span className={styles.Value}>{getMetaValueLabel(value)}</span>
130+
<span
131+
className={styles.Value}
132+
onClick={isInspectable ? toggleIsOpen : undefined}>
133+
{getMetaValueLabel(value)}
134+
</span>
131135
</div>
132136
);
133137
} else {
@@ -165,7 +169,11 @@ export default function KeyValue({
165169
onClick={hasChildren ? toggleIsOpen : undefined}>
166170
{name}
167171
</span>
168-
<span className={styles.Value}>{displayName}</span>
172+
<span
173+
className={styles.Value}
174+
onClick={hasChildren ? toggleIsOpen : undefined}>
175+
{displayName}
176+
</span>
169177
</div>,
170178
);
171179
} else {
@@ -211,7 +219,11 @@ export default function KeyValue({
211219
onClick={hasChildren ? toggleIsOpen : undefined}>
212220
{name}
213221
</span>
214-
<span className={styles.Value}>{displayName}</span>
222+
<span
223+
className={styles.Value}
224+
onClick={hasChildren ? toggleIsOpen : undefined}>
225+
{displayName}
226+
</span>
215227
</div>,
216228
);
217229
}

0 commit comments

Comments
 (0)