Skip to content

Place available breakouts by margin, so a focus ring can't widen the page in Firefox - #5281

Merged
max-sixty merged 6 commits into
mainfrom
fix-firefox-resolve-overflow
Nov 4, 2026
Merged

max-sixty merged 6 commits into
mainfrom
fix-firefox-resolve-overflow

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

In Firefox, resolving a thread left the page scrollable sideways: 456px past a 1728px window on the On me alternatives page. Closing the thread card hands focus to the paragraph beside the thread's subject (letGo in browser/runtime/focus.js), so the paragraph briefly wears a focus ring. Firefox then recomputes the overflow of the ring's holder without laying it out again, and that recomputation counts a child moved by a relative offset or a translate at its place in flow as well as where it is drawn. Since #5056 an available block, and a sidebar Layout in the column's flow, reached the room's start by left, so its place in flow ran from the prose's start to 456px past the window, and the page kept that width until the column next laid out. Chromium doesn't count it. A plain HTML page with no Leaf reproduces it in Playwright Firefox 157 (notes/browser-support.md, "A moved box's place in flow in Firefox's scroll size").

Change

  • An available block or sidebar reaches the room's start by a negative margin on its holder's start side, so its place in flow is where it is drawn. It stays position: relative, with no offset, so its absolutely positioned descendants keep it as their containing block.
  • An available table starts at the room's start by the same margin, and left and translate centre it on the room's axis from there, so its place in flow stays inside the room.
  • The failed-exhibit reset also clears the inline margin.
  • The margin is an ordinary lf-layouts declaration, which gives up Lay out the reading column as block flow, replacing #4858's heading rule #5056's reason for the offset: a page rule that sets the block's inline margins, such as margin: 1rem 0, now replaces it, and the block spills past the window by the room it would have taken, in every engine. page check --render reports that as page-scrolls and names the block past-room, and page-layout.md tells authors to space a data-width block with margin-block. By a selector-name scan, 12 of 252 distinct authored pages with a breakout had a margin rule that may reach one.

Behavior

  • Drawn boxes are unchanged: available blocks, full-room and narrower available tables, and breakouts directly in the column or in a flow read the same edges on main and here, in Firefox and Chromium, left-to-right and right-to-left, at 1728 and 1100px. Stills of twelve breakout states show no pixel change.
  • On the reported page, resolving a thread leaves the root's scroll width at 1728 in Firefox, against 2184 on main, whether the thread is anchored on a playground control or on a paragraph.
  • An available table in a holder whose direction differs from the page's, such as <main dir="rtl"> on a left-to-right page, still widens the page after a ring in Firefox, by up to half the table's width, more than on main, because Firefox applies the table's translate to its place in flow. notes/browser-support.md records it with the ways to close it.

Tests

test_a_breakout_grows_only_from_a_holder_that_spans_the_column and test_a_table_granted_room_stands_on_the_prose_axis now ring a paragraph beside the breakouts and hold the page's sideways scroll at 0. The first fails on main in Firefox, left-to-right. Both pass in Chromium, Firefox and WebKit on this branch merged with main.

This was written by Claude Code on behalf of max-sixty

…page in Firefox

In Firefox, resolving a thread left the page scrollable sideways: 456px past a
1728px window on the On me alternatives page, after `r` and after the panel's
Resolve. Closing the thread card hands focus to the paragraph beside the thread's
subject (`focus.js`, `letGo`), so the paragraph briefly wears a focus ring. Firefox
recomputes the overflow of the ring's holder without laying it out again, and that
recomputation counts a child moved by a relative offset or a translate at its place
in flow as well as where it is drawn. Since #5056 an `available` block, and a
sidebar Layout in the column's flow, reached the room's start by `left`, so its
place in flow ran from the prose's start to 456px past the window, and the page kept
that width until the column next laid out. Chromium never counted it. A plain HTML
page with no Leaf reproduces it in Playwright Firefox 157 (notes/browser-support.md).

## Change

- An `available` block or sidebar reaches the room's start by a negative margin on
  its holder's start side, so its place in flow is where it is drawn. The margin is
  important, since a page rule such as `margin: 1rem 0` on the block would otherwise
  put it back at the prose: that was #5056's reason for the offset, and about 50 of
  730 authored pages with a breakout have a margin rule that may reach one. Its block
  margins stay the page's. `position: relative` goes, since only the offset needed it.
- An `available` table starts at the room's start by the same margin, and `left` and
  `translate` still centre it on the room's axis.
- The failed-exhibit reset also clears the inline margin.

## Behavior

- Drawn boxes are unchanged: available blocks, full-room and narrower available
  tables, and breakouts directly in the column or in a flow read the same edges on
  main and here, in Firefox and Chromium, left-to-right and right-to-left, at 1728
  and 1100px, and with page margin rules on the breakouts. Stills of twelve breakout
  states show no pixel change, only the computed `margin-left` and `position`.
- On the reported page, resolving a thread anchored on a playground control, or on a
  paragraph, leaves the root's scroll width at 1728 in Firefox, against 2184 on main.
- An available table in a holder whose direction differs from the page's, such as
  `<main dir="rtl">` on a left-to-right page, still widens the page after a ring,
  because Firefox applies the table's translate to its place in flow; it now grows
  by half the table's width, more than on main. Recorded in notes/browser-support.md.

## Tests

`test_a_breakout_grows_only_from_a_holder_that_spans_the_column` and
`test_a_table_granted_room_stands_on_the_prose_axis` now ring a paragraph beside the
breakouts and hold the page's sideways scroll at 0. The first fails on main in
Firefox, left-to-right. 59 focused layout, breakout, sidebar, table and gate tests
pass.
…portant

The previous commit placed an `available` block by a negative start margin marked
`!important`, so a page rule such as `margin: 1rem 0` on the block couldn't cancel
it. This drops `!important`: the margin is an ordinary Layout rule, which a page's
own rules adjust as they adjust every other rule in `lf-layouts`, the block's
`inline-size` included.

A page rule that sets the block's inline margins now puts the block back at the
prose's start, where it spills past the window by the room it would have taken, in
every engine. `page check --render` reports that as `page-scrolls` and names each
block `past-room`. `page-layout.md` now tells authors to space such a block with
`margin-block`. Among 252 distinct authored pages with a breakout, 12 had a page
margin rule that may reach one, by a selector-name scan.

The failed-exhibit reset clears the margin as an ordinary declaration too. Drawn
boxes, the Firefox reproducer (1728, against 2184 on main) and the focused layout
tests are unchanged; `test_an_obligation_spanning_its_block_is_a_breakout` fails
with main's `layouts.css` as well.
Moving the breakout by a margin rather than `left` doesn't need it to stop being
positioned, and dropping `position: relative` changed what it is for its
descendants: an absolutely positioned child of an available block took the window
as its containing block instead of the block, and stood at the window's top (astra
review). Keeping it, with no offset, leaves the block's place in flow where it is
drawn, so Firefox's recount still finds nothing past the window: the reported
page resolves at 1728, and the two ring tests pass. The available table rule
no longer repeats it.
@max-sixty
max-sixty merged commit 40e8104 into main Nov 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix-firefox-resolve-overflow branch November 4, 2026 04:44
leaf-agent added a commit that referenced this pull request Nov 5, 2026
… made it (#5499)

`test_available_space_is_a_generic_package_capacity` has failed in every
nightly run since #5056. That change made the reading column a box at
the prose measure, and an `available` block now breaks out of it into
the shell's room. #5056 updated the browser-tier
`test_a_drawing_the_room_can_hold_is_shown_whole` to read that room as
`--lf-shell-width` less a `--col-pad` gutter on each side. This journey
runs only nightly, so #5056's CI never ran it, and it still read the
room as its holder's content box, which is now the 720px prose. The
surface itself was correct: it spanned 1714px of a 1762px window, with
two equal 845px children and no sideways scroll.

The test now reads the room the same way the drawing test does. Its
other expectations are unchanged, and no layout or runtime code changes.
Locally on Linux, `uv run pytest
tests/journeys/test_render_pages.py::test_available_space_is_a_generic_package_capacity
--run-nightly` fails on main with the reported `994 <= 1` and passes
with this change.

<details><summary>When it started</summary>

The test passed in scheduled run 41432142330 (`72afa89ec2`) on Linux and
macOS. It failed in 41622727492 (`19757c94c5`), the first run after
#5056 (`65ac1a06a`) merged. #5281 later changed how the breakout is
offset, but it landed after the first failure and doesn't change the
box's width.

</details>

Closes #5462 — automated triage

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants