Skip to content

Commit

Permalink
ensure useEffect is executed again if ref contents changed since la…
Browse files Browse the repository at this point in the history
…st render
  • Loading branch information
RobinMalfait committed Apr 19, 2024
1 parent b517a39 commit f2e06a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
if (container === getOwnerDocument(container)?.activeElement) return

container?.focus({ preventScroll: true })
}, [data.listboxState, data.optionsRef])
}, [data.listboxState, data.optionsRef, data.optionsRef.current])

let handleKeyDown = useEvent((event: ReactKeyboardEvent<HTMLUListElement>) => {
searchDisposables.dispose()
Expand Down
2 changes: 1 addition & 1 deletion packages/@headlessui-react/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ function ItemsFn<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(
if (container === ownerDocument?.activeElement) return

container.focus({ preventScroll: true })
}, [state.menuState, state.itemsRef, ownerDocument])
}, [state.menuState, state.itemsRef, ownerDocument, state.itemsRef.current])

useTreeWalker({
container: state.itemsRef.current,
Expand Down

0 comments on commit f2e06a1

Please sign in to comment.