Skip to content

Commit

Permalink
Merge pull request Expensify#35454 from akinwale/task-34875
Browse files Browse the repository at this point in the history
fix: prevent crash on Backspace press when magic input is not focused
  • Loading branch information
grgia authored Feb 2, 2024
2 parents cac0a85 + a076395 commit 3ab4e6e
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 3ab4e6e

Please sign in to comment.