Skip to content

Commit eaa7239

Browse files
authored
Fix our formatted field's validation (#4389)
1 parent c216065 commit eaa7239

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/@react-aria/color/src/useColorField.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export function useColorField(
9191
useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);
9292

9393
let onChange = value => {
94-
state.setInputValue(value);
94+
if (state.validate(value)) {
95+
state.setInputValue(value);
96+
}
9597
};
9698

9799
let {labelProps, inputProps} = useFormattedTextField(

packages/@react-aria/numberfield/src/useNumberField.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldSt
176176
}
177177

178178
let onChange = value => {
179-
state.setInputValue(value);
179+
if (state.validate(value)) {
180+
state.setInputValue(value);
181+
}
180182
};
181183

182184
let domProps = filterDOMProps(props);

0 commit comments

Comments
 (0)