Skip to content

Commit cddde45

Browse files
muratcatalbvaughn
andauthored
apply changes on editablevalue on blur feature implemented (#17062)
* apply changes on editablevalue on blur feature implemented * Removed "Undo" button and unnecessary event.preventDefault() Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
1 parent d6e08fe commit cddde45

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*/
99

1010
import React, {Fragment, useRef} from 'react';
11-
import Button from '../Button';
12-
import ButtonIcon from '../ButtonIcon';
1311
import styles from './EditableValue.css';
1412
import {useEditableValue} from '../hooks';
1513

@@ -51,9 +49,7 @@ export default function EditableValue({
5149

5250
switch (event.key) {
5351
case 'Enter':
54-
if (isValid && hasPendingChanges) {
55-
overrideValueFn(path, parsedValue);
56-
}
52+
applyChanges();
5753
break;
5854
case 'Escape':
5955
reset();
@@ -63,6 +59,12 @@ export default function EditableValue({
6359
}
6460
};
6561

62+
const applyChanges = () => {
63+
if (isValid && hasPendingChanges) {
64+
overrideValueFn(path, parsedValue);
65+
}
66+
};
67+
6668
let placeholder = '';
6769
if (editableValue === undefined) {
6870
placeholder = '(undefined)';
@@ -75,21 +77,14 @@ export default function EditableValue({
7577
<input
7678
autoComplete="new-password"
7779
className={`${isValid ? styles.Input : styles.Invalid} ${className}`}
80+
onBlur={applyChanges}
7881
onChange={handleChange}
7982
onKeyDown={handleKeyDown}
8083
placeholder={placeholder}
8184
ref={inputRef}
8285
type="text"
8386
value={editableValue}
8487
/>
85-
{hasPendingChanges && (
86-
<Button
87-
className={styles.ResetButton}
88-
onClick={reset}
89-
title="Reset value">
90-
<ButtonIcon type="undo" />
91-
</Button>
92-
)}
9388
</Fragment>
9489
);
9590
}

0 commit comments

Comments
 (0)