fix(ui): dismiss account menu on route change; stop dropdown swallowing nav clicks#574
Open
eliran-ops wants to merge 2 commits intomainfrom
Open
fix(ui): dismiss account menu on route change; stop dropdown swallowing nav clicks#574eliran-ops wants to merge 2 commits intomainfrom
eliran-ops wants to merge 2 commits intomainfrom
Conversation
…ng nav clicks Two routing-adjacent dismissal bugs (SKY-822): 7. Clicking a tab while a dropdown is open (e.g. Resources during the namespace dropdown) silently swallowed the click — no navigation, no apparent dropdown state change. Root cause: NamespaceSelector mounted a `fixed inset-0 z-[9998]` overlay above the entire viewport to detect outside clicks. The overlay's onClick closed the dropdown but, being above the nav, also ate the user's click — so Resources never received it. 8. Account menu (avatar dropdown) did not dismiss when navigating to a different page. Root cause: UserMenu lives in the app shell and survives router transitions, so its open `isOpen` state persisted across navigations. Nothing was listening for popstate. Fixes: - New shared `useDismissable` hook in `packages/k8s-ui/src/hooks/` covering pointerdown-outside, Escape, and popstate dismissal in one declarative call. 7 unit tests pin the listener-attachment contract. - `UserMenu` now uses `useDismissable`, so the menu closes on outside click, Escape, AND route change. - `NamespaceSelector`'s click-eating backdrop is removed — the existing document-level mousedown listener already handled outside clicks cleanly. With the backdrop gone, a click on e.g. the Resources nav while the dropdown is open closes the dropdown AND navigates, which is what the user expects. - `NamespaceSelector` also gets a popstate listener so the dropdown closes on browser navigation. Linear: SKY-822 Made-with: Cursor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b48ca0a. Configure here.
Cursor Bugbot caught the mismatch: the comment, JSDoc, and handler name all reference `pointerdown` (chosen so we'd cover touch + pen in addition to mouse), but the addEventListener call was registering for `mousedown`. The touch/pen benefits described in the comment weren't actually delivered. Switch the listener to `pointerdown` and update the handler signature to `PointerEvent`. PointerEvent is supported across all browsers radar targets (Chromium, Safari 13+, Firefox 59+). Made-with: Cursor
Contributor
Author
|
@nadaverell @hisco — ready for review. Cursor bugbot found 1 issue on an earlier commit ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Two routing-adjacent dismissal bugs (SKY-822):
Root cause
Fix
Test plan
Made with Cursor
Note
Medium Risk
Changes global event-listener behavior for overlay dismissal (including switching to document-level
pointerdownand addingpopstatehandling), which could affect interaction timing or close overlays unexpectedly if container refs are misconfigured.Overview
Introduces a reusable
useDismissablehook (exported frompackages/k8s-ui) that attaches globalpointerdown,keydown(Escape), andpopstatelisteners to dismiss transient overlays, with opt-outs and container refs to treat multiple elements as “inside”.Updates
UserMenuto useuseDismissableinstead of its ad-hoc outside-clickuseEffect, fixing the menu staying open across route changes. UpdatesNamespaceSelectorto close onpopstateand removes the viewport-wide backdrop so outside clicks dismiss without swallowing the underlying navigation click.Reviewed by Cursor Bugbot for commit 0fc6ff6. Bugbot is set up for automated code reviews on this repo. Configure here.