Skip to content

Commit 4b59d4b

Browse files
use blur events for updating assertion value
1 parent ccb1545 commit 4b59d4b

File tree

1 file changed

+14
-2
lines changed
  • web/renderer/components/pageComponents/DatabasePage/ForTests/TestItem

1 file changed

+14
-2
lines changed

web/renderer/components/pageComponents/DatabasePage/ForTests/TestItem/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function TestItem({
4141
onDeleteTest,
4242
}: Props) {
4343
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
44+
const [localAssertionValue, setLocalAssertionValue] = useState(test.assertionValue);
4445
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
4546

4647
const debouncedOnUpdateTest = useCallback(
@@ -64,6 +65,10 @@ export default function TestItem({
6465
[],
6566
);
6667

68+
useEffect(() => {
69+
setLocalAssertionValue(test.assertionValue);
70+
}, [test.assertionValue]);
71+
6772
const handleDeleteClick = (e: MouseEvent) => {
6873
e.stopPropagation();
6974
setShowDeleteConfirm(true);
@@ -78,6 +83,12 @@ export default function TestItem({
7883
setShowDeleteConfirm(false);
7984
};
8085

86+
const handleAssertionValueBlur = () => {
87+
if (localAssertionValue !== test.assertionValue) {
88+
onUpdateTest("assertionValue", localAssertionValue);
89+
}
90+
};
91+
8192
return (
8293
<li
8394
className={cx(
@@ -215,8 +226,9 @@ export default function TestItem({
215226
<div className={css.fieldGroup}>
216227
<FormInput
217228
label="Assertion Value"
218-
value={test.assertionValue}
219-
onChangeString={value => onUpdateTest("assertionValue", value)}
229+
value={localAssertionValue}
230+
onChangeString={setLocalAssertionValue}
231+
onBlur={handleAssertionValueBlur}
220232
placeholder="Expected result"
221233
className={css.fullWidthFormInput}
222234
/>

0 commit comments

Comments
 (0)