diff --git a/src/accessibility/RovingTabIndex.tsx b/src/accessibility/RovingTabIndex.tsx index 75fc461cc4..d35a0291c3 100644 --- a/src/accessibility/RovingTabIndex.tsx +++ b/src/accessibility/RovingTabIndex.tsx @@ -382,9 +382,13 @@ export const useRovingTabIndex = ( }, []); // eslint-disable-line react-hooks/exhaustive-deps const onFocus = useCallback(() => { + if (!nodeRef.current) { + console.warn("useRovingTabIndex.onFocus called but the react ref does not point to any DOM element!"); + return; + } context.dispatch({ type: Type.SetFocus, - payload: { node: nodeRef.current } as { node: T }, + payload: { node: nodeRef.current }, }); }, []); // eslint-disable-line react-hooks/exhaustive-deps