Skip to content

Commit

Permalink
[@mantine/core] PinInput: Fix incorrect Backspace key handling on t…
Browse files Browse the repository at this point in the history
…he first input (#6880)
  • Loading branch information
Kenzo-Wada authored Sep 25, 2024
1 parent b4f9628 commit 81440bc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/@mantine/core/src/components/PinInput/PinInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,15 @@ export const PinInput = factory<PinInputFactory>((props, ref) => {
} else if (key === 'Delete') {
setFieldValue('', index);
} else if (key === 'Backspace') {
setFieldValue('', index);
if (length === index + 1) {
if ((event.target as HTMLInputElement).value === '') {
if (index !== 0) {
setFieldValue('', index);
if (length === index + 1) {
if ((event.target as HTMLInputElement).value === '') {
focusInputField('prev', index, event);
}
} else {
focusInputField('prev', index, event);
}
} else {
focusInputField('prev', index, event);
}
} else if (inputValue.length > 0 && key === _value[index]) {
focusInputField('next', index, event);
Expand Down

0 comments on commit 81440bc

Please sign in to comment.