Skip to content

Commit 64f50f0

Browse files
author
Murat Çatal
committed
apply changes on editablevalue on blur feature implemented
1 parent 22b2642 commit 64f50f0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export default function EditableValue({
5151

5252
switch (event.key) {
5353
case 'Enter':
54-
if (isValid && hasPendingChanges) {
55-
overrideValueFn(path, parsedValue);
56-
}
54+
applyChanges();
5755
break;
5856
case 'Escape':
5957
reset();
@@ -63,6 +61,17 @@ export default function EditableValue({
6361
}
6462
};
6563

64+
const handleBlur = event => {
65+
event.stopPropagation();
66+
applyChanges();
67+
};
68+
69+
const applyChanges = () => {
70+
if (isValid && hasPendingChanges) {
71+
overrideValueFn(path, parsedValue);
72+
}
73+
};
74+
6675
let placeholder = '';
6776
if (editableValue === undefined) {
6877
placeholder = '(undefined)';
@@ -77,6 +86,7 @@ export default function EditableValue({
7786
className={`${isValid ? styles.Input : styles.Invalid} ${className}`}
7887
onChange={handleChange}
7988
onKeyDown={handleKeyDown}
89+
onBlur={handleBlur}
8090
placeholder={placeholder}
8191
ref={inputRef}
8292
type="text"

0 commit comments

Comments
 (0)