Skip to content

Commit

Permalink
prevent crash on Backspace press when magic input is not focused
Browse files Browse the repository at this point in the history
  • Loading branch information
akinwale committed Jan 31, 2024
1 parent 4e88eea commit a076395
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/MagicCodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function MagicCodeInput(

const indexToFocus = numbers[editIndex] === CONST.MAGIC_CODE_EMPTY_CHAR ? indexBeforeLastEditIndex : editIndex;
const formElement = inputRefs.current as HTMLFormElement | null;
(formElement?.[indexToFocus] as HTMLInputElement).focus();
(formElement?.[indexToFocus] as HTMLInputElement)?.focus();
onChangeTextProp(value.substring(0, indexToFocus));

return;
Expand Down

0 comments on commit a076395

Please sign in to comment.