Skip to content

Commit 4490fb0

Browse files
committed
Split effect for formatting checks
1 parent 41eef42 commit 4490fb0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/react/src/number-field/input/NumberFieldInput.tsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,21 @@ export const NumberFieldInput = React.forwardRef(function NumberFieldInput(
9090

9191
if (validationMode === 'onChange') {
9292
commitValidation(value);
93-
} else {
94-
if (blockRevalidationRef.current) {
95-
blockRevalidationRef.current = false;
96-
return;
97-
}
98-
commitValidation(value, true);
9993
}
10094
}, [value, inputValue, name, clearErrors, validationMode, commitValidation]);
10195

96+
useModernLayoutEffect(() => {
97+
if (prevValueRef.current === value || validationMode === 'onChange') {
98+
return;
99+
}
100+
101+
if (blockRevalidationRef.current) {
102+
blockRevalidationRef.current = false;
103+
return;
104+
}
105+
commitValidation(value, true);
106+
}, [commitValidation, validationMode, value]);
107+
102108
useModernLayoutEffect(() => {
103109
prevValueRef.current = value;
104110
prevInputValueRef.current = inputValue;

0 commit comments

Comments
 (0)