← Back to Pull requests

Anchor menus inside size containers to their button #519

Open
unknown opened this pull request with 556 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 21, 2026 02:40 UTC
Author

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/utils from 0.2.9 to 0.2.12. 0.2.12 removes the containerType clause from isContainingBlock. No other file changes.

  • vendor/javascript/@floating-ui--utils.js and @floating-ui--utils--dom.js are replaced with dist/floating-ui.utils.mjs and dist/floating-ui.utils.dom.mjs from 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.rb are updated.

  • @floating-ui/dom and @floating-ui/core 1.7.0 both declare @floating-ui/utils: ^0.2.9. Every name they import or re-export from utils and utils/dom is still exported by 0.2.12, and the export lists of the two versions are identical. Apart from the containerType removal, the diff from 0.2.9 to 0.2.12 is refactoring: regexes in place of array lookups, a cached isWebKit, hoisted constants. So floating-ui elements outside a size container behave as before. That covers DS::Menu, DS::Popover, DS::Tooltip, and the select, merchant_select, tag_select and tooltip controllers.
  • 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, away from its button | !After: the menu opens under its button |

    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 covers app/javascript/** only, and no file there changed.
  • Diff: 556 lines (+417 / -139) across 6 files Reviewer: jaysbeekay Review duration: 1737m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 556 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.378
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #519"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.5% · Safe to merge
    27.5%