Context menus: stable placement and submenu hover intent (#594) #606
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/594-menu-placement"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #594 (for
dailyuse; thetextchatnightly the report came from gets its own PR, linked below).What was wrong
Reproduced headlessly with
tests/menu_placement.rs(every menu kind at each corner, edge and the centre of 640×480 and 900×600 windows, cursor resting on each submenu row for 8 frames, then moving into the submenu):on_enter(on_submenu(None))), andAnchoredhanded the same cursor to both cards. Moving diagonally from a submenu row toward its submenu crosses other rows of the main card, which closed it. The web client avoids this with floating-ui'ssafePolygon.placeshifted it on the x axis back into the window, over the main card and the row that opened it. With a 344 px submenu in a 640 px window it sat right on its row.dailyuse. Here the main card is placed on its own. The owner's bouncing is ontextchat, whereAnchoredplaced the main card and the submenu as one block. A submenu that ran past the bottom or right edge moved the whole block, main card included, so the cursor ended up over another row, the submenu closed, the block moved back, and the cycle repeated every frame. (iced'smouse_areare-checks hover whenever its bounds change, even without cursor motion.) That one is fixed in the textchat PR.What changed (
widgets/context_menu.rs)inline-end/start, side and alignment flip, fallback axis): right of the row with tops aligned, else bottoms aligned, else the same on the left, else under or above the row. It is shifted only along the row's edge, so it never covers its own row.mouse_areawhether or not a submenu is open, so their state survives open and close.CARD_ID), so tests can find them wherever a menu is drawn.Looks are unchanged: every existing golden passes as-is (
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen).Menus still can't be drawn outside the window. iced overlays live in the window surface, and Wayland gives no way to position a separate popup window, so the fix is stable in-window placement like the web client's.
Tests
crates/fluxer-ui/tests/menu_placement.rscovers the message, channel, voice channel, category, guild, user, DM and voice participant menus, plus a thread-shaped menu (wide and long submenus). It also checks that leaving the safe path still closes the submenu and that a window resize places the menu again. On the old widget 4 of the 5 menu tests fail.tests/headlessgainsHarness::sized,menu_cards,placed_textsandhover_frames, which runs frames the way iced does, keeping the tree.Not covered (follow-ups)
100vh - 1.5remwith a scroller.widgets/popout.rs, profile popout, expression picker, stream hover card) don't have the submenu fault. They re-place on size changes, as the web'sautoUpdatedoes, and nothing hover-driven changes their size.🤖 Generated with Claude Code
The
textchathalf (the bounce the owner saw, which only happens there) is #608.🤖 Generated with Claude Code