Skip to content

fix(ui): keep popup and context menus inside the window (T-3) - #28

Merged
vlidholt merged 1 commit into
mainfrom
fix/menus-inside-screen-t3
Oct 20, 2026
Merged

vlidholt merged 1 commit into
mainfrom
fix/menus-inside-screen-t3

Conversation

@vlidholt

Copy link
Copy Markdown
Contributor

Wonky-Task: T-3
Wonky-Claim: 7HXN-WEKE

Fixes popup and context menus that ran partially off the screen (board report #3).

Cause: WonkyDropdownMenu and the menubar placed their menus with shad's manual ShadAnchor, which glues an overlay to its trigger and never moves it back onto the screen. Context menus flipped above the pointer but ran off the bottom when they were taller than the room on both sides.

Fix: a shared WonkyMenuPlacement in wonky_ui (spec 02 §4.2):

  • WonkyMenuPlacement.onScreen(ShadAnchor) turns a manual anchor into an auto anchor that opens where the anchor says when it fits, on the other side of the trigger (gap mirrored) when it does not, and shifts sideways at the window edges.
  • buildWonkyMenuItems(maxHeight:): menus taller than the larger side of their trigger or pointer scroll, so they always fit on one side.
  • Used by WonkyDropdownMenu, WonkyMenubar, submenus (beside their item, or ending level with its bottom), WonkyContextMenuRegion and WonkyPopupMenuHost.
  • Write's own copy of the popup host is replaced by WonkyPopupMenuHost. Dropdown-like ShadPopovers anchored with a raw ShadAnchor (Drive and board search, notifications, the pivot Add field list) use the same placement.

Acceptance criteria

  • Menus near the bottom or right edge (sheet tab menu, property-panel dropdowns): covered by widget tests that open dropdowns, submenus and context menus near the bottom and right edges. Also checked by hand in the Sheets and Slides release builds.
  • The menu repositions to stay fully visible: it opens upwards when there is no room below, shifts left or right at the edges, and scrolls when it is taller than the room. The tests check that each rendered menu box (border and padding included) lies inside the screen.
  • The fix lives in the shared components: the placement is in wonky_ui (WonkyDropdownMenu, WonkyMenubar, submenus, WonkyContextMenuRegion, WonkyPopupMenuHost), so it applies across Sheets, Slides, Write, Drive and the shell. App code changed only where it bypassed the shared placement.
  • Light and dark styling is kept: menu content and surfaces are unchanged. A test in both brightnesses checks that the repositioned menu keeps the theme's popover surface colour.
  • Undo is unaffected: this is overlay placement only. No commands or state changes are involved.

Tests

  • New: packages/wonky_ui/test/widgets/menu_placement_test.dart (13 tests). The edge, tall-menu and submenu cases fail on the old code.
  • wonky_ui passes in full. wonky_app, Write, Sheets, Slides and Drive pass with -x golden. Goldens are Linux-CI only, and none of them opens a menu.

🤖 Generated with Claude Code

Dropdowns, the menubar and submenus placed their menus with shad's manual
ShadAnchor, which never moves an overlay back onto the screen: the sheet
tab menu ran off the bottom edge and start-aligned menus off the right.
WonkyMenuPlacement turns those anchors into auto anchors that open on the
other side of the trigger when the menu does not fit and shift sideways
at the window edges; menus taller than the room beside their trigger or
pointer scroll. Write's own popup host is replaced by WonkyPopupMenuHost,
and dropdown-like popovers anchored with ShadAnchor use the same
placement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wonky-work-bot

Copy link
Copy Markdown

Wonky task review: T-3: Some popup menus are partially outside of the screen.

The pull request perfectly implements the acceptance criteria by introducing a unified auto-anchoring logic (WonkyMenuPlacement) for menus and popovers, which keeps them securely inside the viewport. All shared UI components were updated to use this new logic, and specific applications bypassing it were properly migrated. Furthermore, the PR includes excellent widget test coverage, verifying behavior in edge cases, large menus, submenus, and dark mode.

Acceptance criterion Verdict Evidence Note
Open a popup or context menu near the bottom or right edge of the window (e.g., the sheet tab menu, or a property panel dropdown). Met packages/wonky_ui/test/widgets/menu_placement_test.dart (67-160), packages/wonky_ui/test/widgets/menu_placement_test.dart (205-223) Tests cover triggering dropdowns and context menus near the bottom and right edges of the screen.
The menu adjusts its position (e.g., opening upwards or shifting left) to remain completely inside the visible screen area. Met packages/wonky_ui/lib/src/widgets/menu/menu_placement.dart (31-42), packages/wonky_ui/lib/src/widgets/menu/dropdown_menu.dart (85-91), packages/wonky_ui/test/widgets/menu_placement_test.dart (102-143) WonkyMenuPlacement.onScreen adds horizontal shift and vertical flip fallbacks, and long menus dynamically scroll.
The fix applies to the shared menu components so it automatically resolves the issue across Sheets, Slides, and other apps. Met packages/wonky_ui/lib/src/widgets/menu/dropdown_menu.dart (112-126), packages/wonky_ui/lib/src/widgets/menubar/menubar.dart (182-240), wonky_write/lib/features/screen/write_document_screen.dart (367-397) The placement overrides are implemented in wonky_ui, and bypassing usages in apps (like Write's duplicated PopupMenuHost) were refactored to use the shared components.
The menu maintains its correct light and dark mode styling when repositioned. Met packages/wonky_ui/test/widgets/menu_placement_test.dart (68-98) Verified by widget tests running in both light and dark mode that assert the correct theme color.
No undo functionality is broken or required for this UI-only overlay behavior. Met packages/wonky_ui/lib/src/widgets/menu/menu_placement.dart (1-103) No state mutation or history logic was modified.

Scope:
No unrelated changes found.

Tests: Added. 13 widget tests were added that thoroughly cover edge positioning, tall menus, submenus, and theme colors.

Specs: Updated. The 02-design-system.md spec was properly updated to document the new WonkyMenuPlacement capabilities.

Facts
  • Changed files: 14 (+571 −149)
  • Tests changed: yes
  • specs/ changed: yes
  • pubspec.yaml changed: no
  • Migrations added: none
  • Workflow or tooling changes: none
  • Security-sensitive paths: none

Reviewed commit 392cd99e3b95. This review is advisory; CI and the maintainers decide.

@vlidholt
vlidholt merged commit 2826091 into main Oct 20, 2026
42 checks passed
@vlidholt
vlidholt deleted the fix/menus-inside-screen-t3 branch October 20, 2026 13:51
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant