Skip to content

Commit

Permalink
fix(number-field): don't trigger onRawValueChange on mount when NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
jer3m01 committed Jul 30, 2024
1 parent 79c21b9 commit 61b6e78
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/number-field/number-field-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function NumberFieldInput<T extends ValidComponent = "input">(
>
as={local.as || "input"}
value={
Number.isNaN(context.rawValue())
Number.isNaN(context.rawValue()) || !context.value()
? ""
: context.formatNumber(context.rawValue())
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/number-field/number-field-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export function NumberFieldRoot<T extends ValidComponent = "div">(
},
});

local.onRawValueChange?.(parseRawValue(value()));
if (value()) local.onRawValueChange?.(parseRawValue(value()));

function isAllowedInput(char: string): boolean {
if (local.allowedInput !== undefined) return local.allowedInput.test(char);
Expand Down

0 comments on commit 61b6e78

Please sign in to comment.