@@ -41,6 +41,7 @@ export default function TestItem({
41
41
onDeleteTest,
42
42
} : Props ) {
43
43
const [ showDeleteConfirm , setShowDeleteConfirm ] = useState ( false ) ;
44
+ const [ localAssertionValue , setLocalAssertionValue ] = useState ( test . assertionValue ) ;
44
45
const debounceRef = useRef < ReturnType < typeof setTimeout > | null > ( null ) ;
45
46
46
47
const debouncedOnUpdateTest = useCallback (
@@ -64,6 +65,10 @@ export default function TestItem({
64
65
[ ] ,
65
66
) ;
66
67
68
+ useEffect ( ( ) => {
69
+ setLocalAssertionValue ( test . assertionValue ) ;
70
+ } , [ test . assertionValue ] ) ;
71
+
67
72
const handleDeleteClick = ( e : MouseEvent ) => {
68
73
e . stopPropagation ( ) ;
69
74
setShowDeleteConfirm ( true ) ;
@@ -78,6 +83,12 @@ export default function TestItem({
78
83
setShowDeleteConfirm ( false ) ;
79
84
} ;
80
85
86
+ const handleAssertionValueBlur = ( ) => {
87
+ if ( localAssertionValue !== test . assertionValue ) {
88
+ onUpdateTest ( "assertionValue" , localAssertionValue ) ;
89
+ }
90
+ } ;
91
+
81
92
return (
82
93
< li
83
94
className = { cx (
@@ -215,8 +226,9 @@ export default function TestItem({
215
226
< div className = { css . fieldGroup } >
216
227
< FormInput
217
228
label = "Assertion Value"
218
- value = { test . assertionValue }
219
- onChangeString = { value => onUpdateTest ( "assertionValue" , value ) }
229
+ value = { localAssertionValue }
230
+ onChangeString = { setLocalAssertionValue }
231
+ onBlur = { handleAssertionValueBlur }
220
232
placeholder = "Expected result"
221
233
className = { css . fullWidthFormInput }
222
234
/>
0 commit comments