Anchor menus inside size containers to their button
Closes jaysbeekay/sure#505.
Upstream PR: we-promise/sure#4370 (draft), on upstream issue we-promise/sure#4366. Same branch, same commit: this pre-flight runs the fork's CI and Gatekeeper reviews on up/floating-ui-container-menus against mirror/upstream-main. It ports jaysbeekay/sure#514 (fork main) onto upstream main.
Problem
A DS::Menu whose button sits inside an element with container-type (Tailwind @container) opens away from its button. It is offset up and left by that element's distance from the viewport's top-left corner. On main this affects every row "..." menu on Bills > All bills, in both the list and the table layout. On a wide window the menu lands over unrelated content, and on a phone the full-width menu can open above the page header.
The cause is in the vendored @floating-ui/utils 0.2.9. Its isContainingBlock counts any containerType other than normal as the containing block of a position: fixed element. Browsers do not, so floating-ui returns coordinates relative to the container while the browser applies them to the viewport.
Change
- Bump
@floating-ui/utilsfrom 0.2.9 to 0.2.12. 0.2.12 removes thecontainerTypeclause fromisContainingBlock. No other file changes. vendor/javascript/@floating-ui--utils.jsand@floating-ui--utils--dom.jsare replaced withdist/floating-ui.utils.mjsanddist/floating-ui.utils.dom.mjsfrom the npm 0.2.12 tarball. Below a two-line source header, each file is byte-identical to the tarball file, and the tarball matches the registry's published sha512 integrity.- The version comments on the two pins in
config/importmap.rbare updated. @floating-ui/domand@floating-ui/core1.7.0 both declare@floating-ui/utils: ^0.2.9. Every name they import or re-export fromutilsandutils/domis still exported by 0.2.12, and the export lists of the two versions are identical. Apart from thecontainerTyperemoval, the diff from 0.2.9 to 0.2.12 is refactoring: regexes in place of array lookups, a cachedisWebKit, hoisted constants. So floating-ui elements outside a size container behave as before. That coversDS::Menu,DS::Popover,DS::Tooltip, and theselect,merchant_select,tag_selectandtooltipcontrollers.
Left out on purpose: bumping dom and core, and per-view workarounds such as moving menus out of containers or a custom platform per controller.
Screenshots
Captured by a system test against the test fixtures: before on main at 7917bc1e4, after on this branch. Bills > All bills with the first row's "..." menu open.
Before (@floating-ui/utils 0.2.9) | After (0.2.12) |
|---|---|
![]() | ![]() |
Before, the menu opens at the top left of the page, a container's width away from its button. After, it opens under the button.
Tests
New test/system/bill_menu_position_test.rb opens the first row menu inside the @container on Bills > All bills and measures the menu against its own button:
- Desktop (1400x1400): the menu's right edge is within 1px of the button's (
placement: "bottom-end"), and the menu sits beside the button. - Phone (375x812): the menu sits beside the button.
- "Beside" means a gap of 0 to 20px, measured below the button or above it when
flip()placed the menu on top. A legitimate flip therefore cannot fail the test.
On this branch, against remote Chromium (selenium/standalone-chromium), both tests pass. With both vendored utils files restored to main's 0.2.9 they fail: desktop Expected |936 - 475| (461) to be <= 1; phone menu is 128px from its button. A node check of isContainingBlock gives true for container-type: inline-size and size on 0.2.9 and false on 0.2.12. transform, filter, will-change: transform and contain: paint stay true on both.
bin/rails test: 12474 runs, 0 failures, 0 errors, 36 skips.test/system/bill_menu_position_test.rb: 2 runs, 0 failures (remote Chromium). The full system suite runs in CI.bin/rubocop: no offenses.bin/brakeman --no-pager: no warnings. Biome coversapp/javascript/**only, and no file there changed.

