← Back to Pull requests

Anchor menus inside size containers to their button #514

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 20, 2026 15:45 UTC
Author

<!-- claude-projects-attribution: {"github_login":"jaysbeekay"} -->
_Requested by Jonathan · project thread_

Summary

Closes #505.

Before: a "..." menu inside an @container opened far from its button. On Bills › All bills it landed 445px left of the button, which is the container's offset. On a phone it landed above the page header. The Portfolio page's menu did the same, and so did the old inline bill pane in the report.

After: the menu opens against its button. On desktop the right edges align, below the button or flipped above it. On a phone it spans the screen directly under the button.

@floating-ui/utils 0.2.9 counted any container-type ancestor as the containing block of a position: fixed element. Browsers don't, so the menu's coordinates were measured from the container while the browser applied them to the window. 0.2.12 drops that check.

How: only @floating-ui/utils moves, from 0.2.9 to 0.2.12. Both vendored utils files are replaced from the npm tarball, and the importmap version comments are updated. dom and core 1.7.0 accept ^0.2.9, and every name they import is still exported. Apart from the containerType removal, the utils diff is refactoring.

Scope and dependencies

  • Issue: #505 (Issue Gatekeeper review landed as NEEDS_CLARIFICATION. Its one finding is addressed and the plan was revised in place.)

  • Parent PR/branch, if stacked: none

  • Intentionally out of scope: bumping @floating-ui/dom/core to 1.8.0; per-view workarounds that move menus out of containers. The files are vendored from npm because jspm is unreachable from the build sandbox; bin/importmap pin would fetch the same 0.2.12 dist, minified.
  • Evidence checklist

  • Each issue in this PR has its own acceptance criteria and no unrelated issue work is included.

  • Contract rows touched by this change name existing tests. (No contract rows touched; new BillMenuPositionTest.)

  • Any gate test has an observed failing mutation transcript attached. (Below.)

  • Fixtures used as evidence assert internal consistency. (The bill is created in the test; both assertions measure the menu against its own button.)

  • Financial calculations use BigDecimal and documented rounding points. (N/A: presentation only.)

  • De-identification uses token-shape allowlists; no personal data is included.

  • Files changed, decisions, tests/runtime, risks, and next unblocked issue are documented below.
  • Files: vendor/javascript/@floating-ui--utils.js, vendor/javascript/@floating-ui--utils--dom.js, config/importmap.rb, test/system/bill_menu_position_test.rb (new).

    Validation

    Commands and results (local, Ruby 3.3.6, Chromium 141):

  • bin/rails test test/system/bill_menu_position_test.rb on 0.2.12: 2 runs, 0 failures.

  • Same with only @floating-ui--utils--dom.js restored to 0.2.9 (mutation):

  •   Expected |948 - 503| (445) to be <= 1.
      menu is 118px from its button, expected it beside it (button {"bottom"=>331, "left"=>315, "right"=>351, "top"=>295}, menu {"bottom"=>177, "left"=>0, "right"=>375, "top"=>61})
      2 runs, 2 assertions, 2 failures
      

  • bin/rails test:system: 215 runs, 0 failures, 0 errors.

  • bin/rails test: 12444 runs, 1 failure. The failure is Provider::OpenaiTest#test_extra_headers_stringifies_nested_values_Ruby-style, which expects Ruby 3.4's Hash#inspect format. It fails only because the sandbox runs Ruby 3.3.6 and is unrelated to this change.

  • bin/brakeman --no-pager: 0 warnings. bin/rubocop on the new test: no offenses. Biome only covers app/javascript/*, and no file there changed.

  • Headless browser, before/after (button right edge vs menu right edge): All bills 1015 vs 570 → 1015 vs 1015. Portfolio 1027 vs 582 → 1027 vs 1027. Overview drawer (no container ancestor) 1439 vs 1439 both before and after.

  • Checked against upstream AGENTS.md: Minitest system test, no new dependency (version bump of an existing pin), commit subjects under 72 characters, no UI or design-token changes.
  • Risks, blockers, and follow-up

  • Every floating-ui caller (DS::Menu, DS::Popover, DS::Tooltip, the select, merchant_select, tag_select and tooltip controllers) picks up the new utils. Behaviour changes only for elements with a container-type ancestor, which is the fix. The full system suite is green.

  • Production was still running a pre-7-October image when this was reported (inline bill pane). Deploying current main with this change fixes both the All bills and Portfolio menus.
  • <!-- This is an auto-generated description by cubic. -->
    <a href="https://cubic.dev/pr/jaysbeekay/sure/pull/514?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture>`&lt;source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"&gt;&lt;source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"&gt;&lt;img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"&gt;</picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/jaysbeekay/sure/514?returnTo=https%3A%2F%2Fgithub.com%2Fjaysbeekay%2Fsure%2Fpull%2F514&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture>``&lt;source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"&gt;&lt;source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"&gt;&lt;img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"&gt;```</picture></a>
    <!-- End of auto-generated description by cubic. -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Bug Fixes
    Improved bill menu positioning across desktop and mobile layouts, keeping menus aligned with their controls and positioned nearby on smaller screens.

    Tests
    Added coverage for bill menu placement across desktop and phone-sized viewports.

    Chores
    * Updated positioning utilities to support more consistent layout behavior across browsers.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: jaysbeekay Review duration: 2392m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.57) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    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%
    46%
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #514"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 57% (MEDIUM) · Higher = larger blast radius
    57%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 30.4% · Safe to merge
    30.4%