Skip to content

fix(navbar): clear pending hide timer before rescheduling in useNavDropdowns - #476

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-475
Oct 26, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-475

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Fixes an issue where useNavDropdowns orphans a hide timer when leaving via the menu. The hideMenu and language-switcher handleMouseLeave functions were scheduling new timeouts without clearing existing ones. When both the container and menu mouseleave events fire (which happens when leaving through the open menu), two timers are created but only the last is tracked, causing the orphaned timer to fire and close the dropdown even after re-entering.

Closes #475

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…opdowns

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 26, 2026

Copy link
Copy Markdown

❌ Deploy Preview for hivecommons-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 9e6fef7
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6adede0fe36dad4d85a1047a

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the full hook at 9e6fef7 plus the existing tests. The fix is correct and minimal; looks correct to me.

Why the bug is real (verified in the tree, not the body): hideMenu is registered on both the container (useNavDropdowns.ts:92) and its descendant [data-dropdown-menu] (:109). Leaving through the open menu fires both mouseleave events, so before this change two timers were created and timeoutRef kept only the second — showMenu's clearHideTimeout() (:43) could never reach the first. Same dual wiring for the language switcher: handleMouseLeave is bound on langSwitcher (:222) and on the observed listbox (:249). Adding the clear at :79 and :183-186 makes the ref the single source of truth; the inline clear in the lang-switcher branch matches the existing pattern in handleMouseEnter (:152-155), since the per-container clearHideTimeout helper is not in scope there.

Suggestion (not a defect): src/__tests__/useNavDropdowns.test.tsx covers single-mouseleave + re-enter (:116, :128) but not the regressing path — mouseLeave(menu) then mouseLeave(container), re-enter, advance 300ms, assert the menu is still shown. A one-case addition would pin this.

CI: the four red Netlify checks are the known quota exhaustion ruled on in #419, not this change; code checks are green.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read src/components/navbar/useNavDropdowns.ts at 9e6fef7 plus the existing navbar tests. This looks correct to me.

Mechanism verified in the tree: hideMenu is registered on both container mouseleave (useNavDropdowns.ts:92) and menu mouseleave (:109), and menu is a descendant of container (:31). Leaving the page through the open menu therefore fires both listeners; before this change each call did a bare setTimeout into the single shared timeoutRef (:22), so the first timer was overwritten and never cleared. Re-entering within DROPDOWN_HIDE_DELAY_MS ran clearHideTimeout() (:35-40) against only the second timer, and the orphan still hid the menu. Adding clearHideTimeout() at :79 closes that gap.

The same pattern exists on the language-switcher side: handleMouseLeave is bound to langSwitcher mouseleave (:222) and is also invoked from the listbox's mouseleave (:248-250), so the inline clear at :183-186 is the right fix there too. It is written inline rather than via clearHideTimeout because that helper is scoped inside the dropdownContainers.forEach closure; the inline form matches the pre-existing clears at :152-155 and :243-246, so it is consistent with the file.

No behaviour change beyond the fix; the effect cleanup at :279 still clears whatever is tracked.

Suggestion (not a defect): src/__tests__/Navbar.behavior.test.tsx:177-200 covers a single-container mouseleave only. A regression test that fires mouseLeave on the [data-dropdown-menu] element and then on its container, re-enters before the delay, and asserts the menu is still visible after DROPDOWN_HIDE_DELAY_MS would pin this fix.

CI: Lint and build, TypeScript & ESLint, Run unit tests and Audit production dependencies all pass. The four red checks are all Netlify (deploy-preview, Header rules, Pages changed, Redirect rules), consistent with the Netlify quota situation recorded in #419 — not caused by this diff.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 0ea9ca3 into main Oct 26, 2026
6 of 11 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-475 branch October 26, 2026 05:08
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#4769e6fef7` sha256:d997212b151a50f8e10c21d6bb13e902686a12e483c686eb36ca71e7ff711f84 — download from the dashboard or `hivectl review evidence #476`.

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026
hivecommons-hive Bot added a commit to thatguywob/docs-1 that referenced this pull request Oct 26, 2026
changelog.d/fixed-475.md already exists from hivecommons#476; the extra fragment
would emit a second release-notes line for the same fix.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
thatguywob added a commit to thatguywob/docs-1 that referenced this pull request Oct 27, 2026
Share clearHideTimeout between navbar dropdowns and the language switcher. Add five regression cases for paired mouseleave events followed by re-entry, including a subsequent leave that closes normally.

Refs hivecommons#475. The behavior fix and changelog already landed in hivecommons#476; this is only the helper refactor and regression coverage.

Signed-off-by: thatguywob <thatguywob@users.noreply.github.com>
clubanderson pushed a commit that referenced this pull request Oct 27, 2026
…477)

Share clearHideTimeout between navbar dropdowns and the language switcher. Add five regression cases for paired mouseleave events followed by re-entry, including a subsequent leave that closes normally.

Refs #475. The behavior fix and changelog already landed in #476; this is only the helper refactor and regression coverage.

Signed-off-by: thatguywob <thatguywob@users.noreply.github.com>
Co-authored-by: thatguywob <thatguywob@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] fix(navbar): useNavDropdowns orphans a hide timer when leaving via the menu, closing the dropdown under the cursor

0 participants