From cc1704fcedb889fd1419c364fd8bbd86ed3376b2 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Thu, 11 Jan 2024 17:30:52 +0100 Subject: [PATCH] Fix type of `listRef` and `useFloatingItemProps.ref` --- src/floating.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/floating.tsx b/src/floating.tsx index 0d3355d..8945afd 100644 --- a/src/floating.tsx +++ b/src/floating.tsx @@ -47,7 +47,7 @@ type Context = { }; refs: Pick["refs"], "setReference" | "setFloating"> & { arrowRef: React.MutableRefObject; - listRef: React.MutableRefObject; + listRef: React.MutableRefObject>; }; getReferenceProps: ReturnType["getReferenceProps"]; getFloatingProps: ReturnType["getFloatingProps"]; @@ -70,7 +70,7 @@ export const useFloatingItemProps = () => { const context = useFloatingContext(); return (index: number) => ({ tabIndex: context.activeIndex === index ? 0 : -1, - ref: (node: HTMLElement) => { + ref: (node: HTMLElement | null) => { if (context.refs.listRef.current !== null) { context.refs.listRef.current[index] = node; } @@ -162,7 +162,7 @@ export const FloatingContainer = React.forwardRef(null); const div = useRef(null); - const listRef = useRef([]); + const listRef = useRef>([]); useImperativeHandle(ref, () => Object.assign(div.current ?? unreachable(), { open: () => setOpen(true),