Skip to content

Commit

Permalink
Handle key property not being set on event in some circumstances
Browse files Browse the repository at this point in the history
When an input is auto completed by chrome (e.g password/username) it triggers an event that scoutbar is listenting to but excludes the "key" property. This throws an exception when calling toLowerCase on undefined
  • Loading branch information
danielcherrington authored Apr 24, 2023
1 parent 6b40e70 commit fae71c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/use-scout-shortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const useScoutShortcut = (
const handler = useCallback(
(event: KeyboardEvent, key: string, position) => {
const overrideKeyForOption =
!ROOT_KEY_MAPS.includes(event.key.toLowerCase()) &&
!ROOT_KEY_MAPS.includes(event.key?.toLowerCase()) &&
ignoreStrokes((event.target as HTMLElement).tagName);
/** Check If the key is already pressed, do nothing */
if (event.repeat) return;
Expand Down

0 comments on commit fae71c8

Please sign in to comment.