fix: ui bugs

This commit is contained in:
Sajad Mirjalili
2025-11-28 16:15:43 +03:30
parent 3ef73a0360
commit 2a6dd67cb4
19 changed files with 165 additions and 182 deletions

View File

@@ -57,10 +57,20 @@ const DigitInput: React.FC<DigitInputProps> = ({
event: KeyboardEvent<HTMLDivElement>,
index: number,
) => {
if (event.key === 'Backspace' && code[index]) {
if (event.key === 'Backspace') {
event.preventDefault();
handleChange('', index);
if (index > 0) inputRefs.current[index - 1]?.focus();
if (code[index]) {
// We clear the current value.
handleChange('', index);
} else if (index > 0) {
// We move focus to the previous input and SELECT its content.
const prevInput = inputRefs.current[index - 1];
if (prevInput) {
prevInput.focus();
prevInput.select();
}
}
}
};