Skip to content

Commit

Permalink
- Fix for delete of decimalSeparator happening when fixeDecimalScale …
Browse files Browse the repository at this point in the history
…is set. #789
  • Loading branch information
s-yadav authored and aashu16 committed Sep 8, 2023
1 parent 49efe28 commit 7251666
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/numeric_format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,13 @@ export function useNumericFormat<BaseType = InputAttributes>(
}

// don't allow user to delete decimal separator when decimalScale and fixedDecimalScale is set
if (
key === 'Backspace' &&
value[selectionStart - 1] === decimalSeparator &&
decimalScale &&
fixedDecimalScale
) {
setCaretPosition(el, selectionStart - 1);
e.preventDefault();
if (decimalScale && fixedDecimalScale) {
if (key === 'Backspace' && value[selectionStart - 1] === decimalSeparator) {
setCaretPosition(el, selectionStart - 1);
e.preventDefault();
} else if (key === 'Delete' && value[selectionStart] === decimalSeparator) {
e.preventDefault();
}
}

// if user presses the allowed decimal separator before the separator, move the cursor after the separator
Expand Down

0 comments on commit 7251666

Please sign in to comment.