Skip to content

CSplitButton: in Firefox, a right-to-left split button's menu opens in the wrong place #495

Open

Description

@JuroOravec

In Firefox, the menu of a right-to-left (RTL) CSplitButton opens in the wrong place. In the CSplitButton layers example, the menu lands at x 0 to 224, where Chromium puts it at x 201 to 425. A submenu opened from it then lands off screen, at x −618. Left-to-right split buttons and CMenu are not affected.

The Firefox e2e test test_layers_example_logs_menu_actions_and_opens_the_dialog_for_provenance fails because of this. It also fails on main (measured with Playwright 1.64.1, Firefox 157.0 and Chromium 156.0.8078.4).

This issue is parked until after 0.7.0. It needs a decision on how to fix it, listed below.

Cause

This is a Firefox anchor-positioning bug, and it shows up without any Citry code. In the cases we tested, Firefox misplaces a popover that is inside its own anchor in the DOM when its position-area spans toward the start side (here block-end span-inline-start). Setting justify-self or using physical position-area keywords does not help. The same popover works when it is a sibling of the anchor.

CSplitButton puts anchor-name on its group <div>, and that <div> also contains the menu. In RTL, the menu spans toward the start side, so it hits the bug. In a left-to-right split button, the menu spans toward the end side, so it does not hit the bug. CMenu is anchored to its trigger button, which is a sibling of the menu, not its parent.

Repro

Save this as repro.py and run python repro.py firefox, then python repro.py chromium, to compare. Each line prints the popover's left and right edges for one CSS variant. The script needs Playwright with both browsers installed (pip install playwright, then playwright install firefox chromium).

import sys
from playwright.sync_api import sync_playwright
HTML = """<!doctype html><html dir="ltr"><head><meta charset="utf-8"><style>body{margin:0}
#a{position:absolute;top:87px;left:243px;width:182px;height:40px;background:#ccc;anchor-name:--a;direction:rtl}
#p{position:fixed;margin:0;margin-block-start:6px;padding:0;border:0;position-anchor:--a;direction:rtl;position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline;position-area:block-end span-inline-start;%s;height:86px;background:#9cf;box-sizing:border-box}
</style></head><body><div id="a"><div id="p" popover>x</div></div>
<script>document.getElementById('p').showPopover()</script></body></html>"""
vs = {"auto": "width:224px", "end": "width:224px;justify-self:end", "start": "width:224px;justify-self:start", "right": "width:224px;justify-self:right", "left": "width:224px;justify-self:left", "self-end":"width:224px;justify-self:self-end", "phys-bottom-span-left":"width:224px;position-area:bottom span-left", "ltr-elem":"width:224px;direction:ltr"}
with sync_playwright() as p:
    b = getattr(p, sys.argv[1]).launch()
    page = b.new_page(viewport={"width": 1280, "height": 720})
    for k, v in vs.items():
        page.set_content(HTML % v)
        page.wait_for_timeout(100)
        print(sys.argv[1], k, page.evaluate("(()=>{const r=document.getElementById('p').getBoundingClientRect();return [Math.round(r.left),Math.round(r.right)]})()"))
    b.close()

The popover #p sits inside its anchor #a. In our testing, when #p is moved out of #a so it becomes a sibling, Firefox places it where Chromium does. The script above does not include that variant.

Options

  • (a) Anchor the menu to an element that holds only the two buttons. anchor-name moves to a new wrapper around the primary button and the toggle button, so the menu is no longer inside its anchor. This changes the split button's markup and part structure. It is the robust fix. It also fixes the off-screen submenu, because the submenu is placed relative to the misplaced menu.
  • (b) Anchor the menu to the toggle button. Each placement then needs its own position-area. This is a smaller change, but "start" placements would line up with the toggle button rather than with the whole button group.
  • (c) Leave the markup alone and wait for Firefox. Report the bug to Mozilla, and Firefox users of RTL split buttons see the wrong placement until Firefox fixes it.

Recommendation

Option (a), plus a Mozilla report:

  • (a) fixes the cause in Citry, for every placement.
  • It does not depend on when Firefox ships a fix.
  • It keeps "start" placements aligned with the whole group, which (b) does not.

Before making the change, check the other anchored components (CPopover, CSelect, CMultiSelect, CTooltip, CHoverCard and the CMenu submenus). Any other popup that sits inside its own anchor and spans toward the start side is likely to have the same bug.

Mozilla report (still to be filed)

Not filed yet. It should describe the case above: a popover that is a DOM descendant of its own anchor-name element, with position-area: block-end span-inline-start in an RTL context. Firefox places it differently from Chromium, and justify-self and physical keywords do not change that. The repro above is the test case.

Activity

  1. added
    next-sprint
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions