From 926c45488d8d459e46354e0f910fcec09885f7ad Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Wed, 13 Nov 2024 20:40:46 +0530 Subject: [PATCH] Remove type cast --- src/accessibility/RovingTabIndex.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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