Skip to content

fix(context-menu): auto-close on scroll/resize/visibilitychange (closes #455) - #472

Open
EVWorth wants to merge 1 commit into
mainfrom
fix/455-context-menu-autoclose
Open

fix(context-menu): auto-close on scroll/resize/visibilitychange (closes #455)#472
EVWorth wants to merge 1 commit into
mainfrom
fix/455-context-menu-autoclose

Conversation

@EVWorth

@EVWorth EVWorth commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

The context menu was anchored to absolute x/y coordinates from the right-click. Before this change, it survived:

  • scroll — orphaned, offscreen while the grid scrolls beneath it
  • window resize — same drift
  • OS visibility loss — menu stayed open invisibly

Adds 3 listeners in the existing close-effect:

  • scroll capture-phase (ancestor-aware)
  • resize on window
  • visibilitychange only when state transitions to hidden

5 new tests cover each path + a negative test that 'visible' doesn't close.

Files

  • src/components/common/ContextMenu.tsx
  • src/components/common/tests/ContextMenu.test.tsx (12/12 pass)

Test plan

  • vitest: ContextMenu 12/12
  • vitest: full frontend
  • tsc --noEmit clean
  • eslint clean

Closes #455

#455)

The context menu is anchored to absolute x,y from the right-click.
Before this change, it survived scroll (orphaned, offscreen while grid
scrolls beneath it), window resize (similar drift), and OS-driven
visibility loss (menu stays open invisibly).

Adds 3 listeners in the existing close-effect:
- scroll (capture-phase, ancestor-aware)
- resize (window)
- visibilitychange (only when state -> hidden)

5 new tests cover each path plus a negative test that 'visible'
visibility does NOT close.

Closes #455

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][bug] useContextMenu has no auto-close on scroll/resize — orphaned menu stays mounted

1 participant