fix(Toast): reset the UA popover width so an end toast lands on the end edge - #5822
Open
freddymeta wants to merge 1 commit into
Open
fix(Toast): reset the UA popover width so an end toast lands on the end edge#5822freddymeta wants to merge 1 commit into
freddymeta wants to merge 1 commit into
Conversation
…nd edge A default `bottomEnd` toast renders on the LEFT. Reproduced on a bare page with no application CSS, so it is not a consumer override. The viewport reaches the top layer through `popover="manual"`, and the UA stylesheet gives every popover `width: fit-content`. That was harmless while the element was anchored by `insetInlineEnd: 0` — a shrink-wrapped box sat on the end edge whatever its width. #5353 changed the model: the viewport now spans the inline axis (`viewportInlineSpan` sets both inset edges to 0) and places the toast with `align-items` inside itself. A shrink-wrapped box cannot span. Both inset edges cannot be honoured at once, so the box resolves against the START edge at its content width, and `align-items: flex-end` then aligns the toast to the right of a box that is itself on the left. Every computed value reads correct in isolation, which is what makes it hard to see: `align-items: flex-end` ✓, `inset-inline-start: 0` ✓, `inset-inline-end: 0` ✓ — and `width: 438px` inside a 1200px viewport. Measured in Chromium at 1200px, default position, clean page: as shipped viewport 438px at x=0 toast x=19 ✗ + width: auto viewport 1200px toast x=781 ✓ + inset-inline-start:auto (the pre-#5353 model) toast x=781 ✓ Both spellings fix it; `width: auto` is the one that belongs, because the reset block right there already neutralises `inset`, `margin`, `border` and `background` for exactly this reason and just missed `width`. All four placements after the fix, and a 360px viewport: bottomEnd toast 781..1181 bottomStart toast 19..419 topEnd toast 781..1181 topStart toast 19..419 360px wide toast 19..341, inside the viewport `bottomStart` and `topStart` looked right before this only by accident: a shrink-wrapped box on the start edge is where a start-aligned toast belongs anyway. The new unit test asserts the reset declaration rather than the rendered geometry — jsdom resolves neither UA popover styles nor a cascade, so it cannot see the bug itself, and the existing placement test asserting `width !== '100%'` passed throughout. Negative control: with the declaration removed the test fails `expected '' to be 'auto'`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report
Modified ComponentsToast (@astryxdesign/core)
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual RegressionStatus: No visual change across 238 compared shot(s). Generated by PR Enrichment workflow | View full report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A default
bottomEndtoast renders on the left. Reproduced on a bare page with no application CSS, so it is not a consumer override — and it is in the releasedv0.5.2but notv0.5.0.The viewport reaches the top layer through
popover="manual", and the UA stylesheet gives every popoverwidth: fit-content. That was harmless while the element was anchored byinsetInlineEnd: 0: a shrink-wrapped box sits on the end edge whatever its width.#5353 changed the model — the viewport now spans the inline axis (
viewportInlineSpansets both inset edges to0) and places the toast withalign-itemsinside itself. A shrink-wrapped box cannot span. Both inset edges cannot be honoured at once, so the box resolves against the start edge at its content width, andalign-items: flex-endthen aligns the toast to the right of a box that is itself on the left.Every computed value reads correct in isolation, which is what makes this hard to spot:
What
One declaration, in the UA-reset block that already neutralises
inset,margin,borderandbackgroundfor exactly this reason and just missedwidth.Testing
Chromium, 1200px, default position, clean page:
+ width: auto+ inset-inline-start: auto(pre-#5353 model)Both spellings fix it;
width: autois the one that belongs with the rest of the reset.All four placements after the fix, plus a narrow viewport:
bottomStart/topStartlooked right before this only by accident — a shrink-wrapped box on the start edge is where a start-aligned toast belongs anyway.Full suite: 8887 tests / 316 files pass, typecheck, typecheck:docs, check:repo, lint:strict all clean.
On the test
It asserts the reset declaration, not the rendered geometry. jsdom resolves neither UA popover styles nor a cascade, so it cannot reproduce the bug — the existing placement test asserting
width !== '100%'passed happily throughout. Negative control: with the declaration removed it failsexpected '' to be 'auto'. The rendered proof is the matrix above.If a browser-level guard is wanted instead, this is the same shape as the Chromium guards in
pr-a11yand I am happy to add one.Risk
One property on one element. Defaults for
bottomStart/topStartare unchanged in output;bottomEnd/topEndchange from broken to correct.