Skip to content

Commit ba0a6ab

Browse files
committed
Allow nullable refs (as it should be)
1 parent febefb8 commit ba0a6ab

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/keybinding.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { type RefObject, useCallback, useEffect } from 'react';
33
export type KeybindingProps = {
44
onKey: (e: KeyboardEvent) => void;
55
type?: 'keydown' | 'keyup';
6-
target?: string | HTMLElement | Document | Window | RefObject<HTMLElement>;
6+
target?:
7+
| string
8+
| HTMLElement
9+
| Document
10+
| Window
11+
| RefObject<HTMLElement | null>;
712
preventInputConflict?: boolean;
813
preventContentEditableConflict?: boolean;
914
preventDefault?: boolean;
@@ -14,7 +19,7 @@ const TARGETS_BLACKLIST = ['textarea', 'input', 'select'];
1419

1520
function isRefObject(
1621
target: NonNullable<KeybindingProps['target']>,
17-
): target is RefObject<HTMLElement> {
22+
): target is RefObject<HTMLElement | null> {
1823
return typeof target === 'object' && 'current' in target;
1924
}
2025

0 commit comments

Comments
 (0)