Skip to content

LF-4618 Fix remove error entry when click X on number input #3643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/webapp/src/components/Form/NumberInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function NumberInput<T extends FieldValues>({
...props
}: NumberInputProps<T>) {
const { field, fieldState, formState } = useController({ name, control, rules, defaultValue });
const { inputProps, reset, numericValue, increment, decrement } = useNumberInput({
const { inputProps, numericValue, increment, decrement, clear } = useNumberInput({
initialValue: field.value || get(formState.defaultValues, name) || defaultValue,
allowDecimal,
decimalDigits,
Expand All @@ -86,7 +86,7 @@ export default function NumberInput<T extends FieldValues>({
{...inputProps}
className={className}
error={fieldState.error?.message}
onResetIconClick={reset}
onResetIconClick={clear}
leftSection={currencySymbol}
rightSection={
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export default function useNumberInput({
const stepDecimalPlaces = countDecimalPlaces(step);
const options: Intl.NumberFormatOptions = {
useGrouping,
minimumFractionDigits: !allowDecimal ? undefined : decimalDigits ?? stepDecimalPlaces,
maximumFractionDigits: !allowDecimal ? 0 : decimalDigits ?? (stepDecimalPlaces || 20),
minimumFractionDigits: !allowDecimal ? undefined : (decimalDigits ?? stepDecimalPlaces),
maximumFractionDigits: !allowDecimal ? 0 : (decimalDigits ?? (stepDecimalPlaces || 20)),
};

return createNumberFormatter(locale, options);
Expand Down Expand Up @@ -199,7 +199,8 @@ export default function useNumberInput({
return {
numericValue,
inputProps,
reset: () => update(initialValue ?? NaN),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be appreciated if you could add a comment to this line, like: // TODO: Fix before use (LF-4798)

// TODO: Fix before use (LF-4798)
reset: (value?: number | null) => update(value ? value : NaN),
clear: () => update(NaN),
update,
increment,
Expand Down