next.js
145d7613 - fix: update useEffect closure when menu is truly mounted (#81531)

Commit
163 days ago
fix: update useEffect closure when menu is truly mounted (#81531) Previously we mounted event handlers on the the menu's [`ownerDocument`](https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument) to listen for clicks outside the menu. This causes a bug where the ref the useEffect captures is not set yet, and when it is set the effect does not try to run again. The fix is to derive active state from the true state tracking if the menu is mounted, not if the menu __will be open__ ### Before https://github.com/user-attachments/assets/d88f9b46-2203-45f3-a184-46db39584679 ### After https://github.com/user-attachments/assets/57a0f68f-8d46-41ea-b761-222c82e4b6bc
Author
Parents
Loading