[Bug Fix] DropdownMenu: fix z-index stacking and default placement (#439)
Merged
DJ
5mo ago+17+17+01234567890123456789-10-10-01234567890123456789
Fixes #439
Problems
After the Floating UI port (#158), the DropdownMenu had two issues (reproducible on https://www.rubyui.com/docs/dropdown_menu):
- Open menu renders behind sibling elements. On the Placement grid, opening a menu showed it under neighbouring triggers. The container carried a static
z-50, and so did every sibling dropdown — equal z-index, so paint order fell back to DOM order and later siblings covered an open menu. - First Usage example: menu detached from the "Open" button. Default placement was
top(unusual for a dropdown — convention isbottom), and the demo wrapped the trigger inclass: 'w-full', so Floating UI used the full-width wrapper as the reference and centred the menu over it, far from the small button.
Changes
dropdown_menu_controller.js(gem + docs copy):- default placement
top→bottom. - set
element.style.zIndexonly while the menu is open ("50"on open, cleared on close).
- default placement
dropdown_menu.rb: removed the staticz-50from the container. Closed dropdowns now stack in normal flow (no stacking context), so the one open menu — elevated by the controller — always paints above its neighbours.dropdown_menu_docs.rb+docs/app/views/docs/dropdown_menu.rb: droppedw-fullfrom the Usage trigger so the floating reference matches the visible button.
Testing
cd gem && bundle exec rake→ 237 runs, 0 failures, StandardRB clean.node --checkon both controllers.- Manual: on the docs dropdown page, the Usage menu now opens directly below the "Open" button, and Placement menus paint above neighbouring triggers.
Screenshots
Before/after to be added.
Summary by cubic
Fixes DropdownMenu stacking so open menus render above siblings, and sets the default placement to open below the trigger. Updates docs and MCP registry so the menu positions relative to the button, not a full-width wrapper.
- Bug Fixes
- Removed container
z-50; controller now setszIndex = "50"only while open and clears on close. - Changed default placement from
toptobottomin both controllers. - Docs: dropped
w-fullfromDropdownMenuTrigger; rebuilt MCPregistry.jsonto sync examples.
- Removed container