Skip to content

fix(core)!: a hidden element stays hidden whatever display its styles set - #7525

Closed
vjeux wants to merge 2 commits into
meta:mainfrom
vjeux:reset-hidden-important
Closed

vjeux wants to merge 2 commits into
meta:mainfrom
vjeux:reset-hidden-important

Conversation

@vjeux

@vjeux vjeux commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Why: anyone who hides a styled element with hidden under Astryx's reset: if its styles set display, it stays visible. Astryx itself works around this in three places.

What led to it: one product we're moving onto Astryx carries its own [hidden] fix.

Problem and solution fit

Options and tradeoffs: !important in the reset (this PR; breaking, since pages that show a hidden element through display see it hide); a display: none class beside each hidden, as BottomSheet and the menus do (every product must remember); or a stronger selector without !important (still loses to later layers and unlayered rules).

Why this choice: hidden should hide, as in Tailwind Preflight and Bootstrap Reboot, the resets this file names as models.

Expected behavior and authority

  • The reset's comment: "Ensure hidden elements are actually hidden."
  • spec:AST-017 FR32 makes this [breaking], admitted only in a declared minor (FR31).
  • spec:AST-080 FR3 (current) keeps a product's unlayered CSS above every Astryx layer, and this !important deliberately beats it. The one owner decision: whether FR3 carves out the [hidden] rule.

Smallest restoration

No API change. Migration (in the changeset): drop hidden, or set display with !important inline or in a layer before reset; no codemod can detect reliance on the old result.

Evidence

  • Under main's reset, hidden elements with a later-layer class, an unlayered rule or an inline display compute flex, grid, block; here, all none.
  • Inline and earlier-layer !important still win, until-found keeps content-visibility: hidden, and elements without hidden keep their display. No Astryx component changes: every hidden has no display or already pairs with display: none.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

How to check: <div hidden class="flex"> under the reset computes none here and flex on main.

Evidence: reset.hidden.a11y.browser.spec.ts passes in Chromium (CI) and WebKit 26.5 (local), and its display test fails with main's reset in both; real Safari 18.6 and 26.2 (iOS simulators) match (comment below). reset.hidden.test.ts fails on main and passes here, with the reset, until-found and Pages tests. Lint, typecheck and check:repo pass except check:changesets, which rejects [breaking] on a patch plan, so the commit skipped the hook and ran lint-staged by hand.

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 22, 2026 8:33pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 11, 2026, 1:41 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 14, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval needs a maintainer to provide or identify the governing spec for this new breaking reset.css contract (no current spec covers reset.css, so spec:AST-017 FR33 makes it an owner decision) and to settle its release, since FR31 refuses the [breaking] changeset while main declares 0.7.1 (the routes are an owner bump to 0.8.0 or an opt-in for 0.7.1). Whatever they decide, two fixes are needed:

  • Rebase on main, where #7520 landed the same until-found selector, so all three reset files now conflict.
  • Update the reset.css header, which still says unlayered consumer styles always override every Astryx layer.

[Automated review]

:where([hidden]) {
display: none;
:where([hidden]:not([hidden='until-found' i])) {
display: none !important;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With !important here, this file's header (lines 29–30) stops being true: it still says unlayered consumer styles always override all Astryx layers and that the reset can be overridden by any other layer. Unlayered and later-layer display declarations now lose to this rule even when they are !important themselves (Chromium 149 computes display: none for both). Please carve the [hidden] rule out in that header.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ba58741: the header now says the [hidden] rule's display: none !important is the one exception, beating any display from a later layer or an unlayered style, !important included. The Pages copy and its hash moved with it.

Comment thread .changeset/reset-hidden-important.md Outdated

[breaking] `reset.css` now keeps a `hidden` element hidden when its own styles set `display`. The reset's `[hidden]` rule had zero specificity in the lowest layer, so a `display` from a class, a later layer, an unlayered rule or an inline style showed the element again. The rule is now `display: none !important`, which outranks every layer and unlayered rule; `hidden="until-found"` keeps the browser's own rendering, so find in page can still reveal it.

To keep an element visible while it carries `hidden`, remove the attribute, or set an inline `style="display: … !important"`, the one declaration that still wins. There is no codemod: whether a stylesheet shows a hidden element on purpose cannot be read from its source.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline !important is not the only declaration that still wins: an !important in a cascade layer declared before reset also beats this rule (Chromium 149 computes display: flex). Line 5's "outranks every layer" and the rule's comment in reset.css ("only an inline !important style still wins") overstate it the same way; consider dropping the exclusivity or naming that case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ba58741: the changeset says the rule outranks every later layer and unlayered rule, !important ones included, and the migration names both overrides, inline !important or !important in a layer declared before reset. The rule's comment says the same, and the browser spec checks the earlier-layer case (flex in Chromium 149 and WebKit 26.5).

@vjeux

vjeux commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Real Safari check (iOS simulators, Safari 18.6 and Safari 26.2): hidden elements with a later-layer class, an unlayered rule and an inline display compute flex / grid / block with main's reset and none / none / none with this branch's, in both versions; an inline !important display still computes block. In 26.2, hidden="until-found" with a display class keeps content-visibility: hidden on both arms. Safari 18.6 has no until-found support and shows that element on both arms, as before.

@vjeux

vjeux commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer decision (ENGOWNER), for ba58741:

  1. Governing authority. No record covers reset.css, and this change needs none, because it makes the rule do what its own comment has always said: "Ensure hidden elements are actually hidden". The HTML Standard's rendering section hides [hidden] (other than until-found) with display: none, and the reset's rule exists to keep that true under author styles. Tailwind Preflight and Bootstrap Reboot, which the file names as its models, use !important for the same reason. Under spec:AST-017 FR33, that comment is the pre-existing authority the released behavior violated. The reproducer and the migration are in the description and the changeset.
  2. Release. Proposed; pending owner review, since release planning under spec:AST-017 belongs to its owners: this waits for the next declared minor rather than an opt-in for 0.7.1. An opt-in would add a public switch for one declaration, and that switch would later need its own removal. Until an owner declares the minor, check:changesets stays red by design.

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval needs a maintainer decision first: spec:AST-080 FR3 says a product's unlayered CSS stays above every Astryx layer, and this rule's display: none !important deliberately makes hidden elements beat that CSS, so a maintainer has to amend FR3 to carve out the [hidden] rule or decline the change. If FR3 is amended, the [breaking] changeset can merge only once main declares the 0.8.0 minor (spec:AST-017 FR31, FR48); it declares 0.7.2 today. Independently of that decision, please rebase on main: .github/pages/assets/manifest.json conflicts, so both reset.css copies need main's changes plus this rule and a recomputed hash.

[Automated review]

@vjeux
vjeux force-pushed the reset-hidden-important branch from ba58741 to 69e9433 Compare October 20, 2026 14:14
@vjeux

vjeux commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged: spec:AST-080 FR3 keeps a product's unlayered CSS above every Astryx layer, and this rule's !important deliberately beats it. So this change needs AST-080's owner to amend FR3 with a [hidden] carve-out, or to decline it; that supersedes my earlier note that no record covers reset.css. No code change until then. Rebased on main (69e9433) with the Pages copy and hash regenerated; the description now names FR3, and the changeset stays [breaking] for the 0.8.0 minor.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval needs a maintainer decision first: spec:AST-080 FR3 says a product's unlayered CSS stays above every Astryx layer, and this rule's display: none !important deliberately makes hidden elements beat that CSS, so a maintainer has to update FR3 to carve out the [hidden] rule or decline the change. If FR3 is amended, the [breaking] changeset can merge only once main declares the 0.8.0 minor (spec:AST-017 FR31, FR48); it declares 0.7.2 today. Nothing else needs work: the branch now sits on current main, both reset.css copies and the manifest hash match, and the new tests fail on the old rule and pass on this one.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval needs a maintainer to update an existing spec first: spec:AST-080 FR3 says a product's unlayered CSS stays above every Astryx layer, and this rule's display: none !important deliberately makes hidden elements beat that CSS, so FR3's owner has to carve out the [hidden] rule or decline the change. If FR3 is amended, the [breaking] changeset can merge only once main declares the 0.8.0 minor (spec:AST-017 FR31, FR48); it declares the patch 0.7.3 today, which is why check:changesets fails. The code itself needs no changes: both reset.css copies and the manifest hash match main plus this rule, and the new tests fail on the old rule and pass on this one. When you rebase for the release, the unrelated pr-a11y failure (a step for a spec file main added after this branch's base) clears too.

[Automated review]

… set

The reset's `:where([hidden]) { display: none }` had zero specificity in
the lowest layer, so any `display` from a class, a later layer, an
unlayered rule or an inline style beat it and the hidden element showed:
`<div hidden class="flex">` computed `display: flex` in Chromium and
WebKit. Astryx's own BottomSheet, DropdownMenuSubMenu and menu drill-in
wrapper each pair `hidden` with a separate `display: none` class for that
reason.

The rule is now `display: none !important`, which in the lowest layer
outranks every later layer and unlayered rule; an inline `!important`
style still wins. Tailwind Preflight and Bootstrap Reboot, which the file
names as models, do the same. The selector already skips
`hidden="until-found"` (meta#7520), so the `!important` cannot take that
content out of find in page.

Pages that show an element carrying `hidden` through their own `display`
will now hide it, so the changeset is [breaking] (spec:AST-017 FR32) and
names the migration. `check:changesets` rejects it while main declares a
patch, so this commit skipped the pre-commit hook after its other steps
ran by hand.

The GitHub Pages landing serves a byte-identical copy of the file, which
its test requires to match, so the copy and its manifest hash move with it.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval needs a maintainer to update an existing spec first: spec:AST-080 FR3 says a product's unlayered CSS stays above every Astryx layer, and this rule's display: none !important deliberately makes hidden elements beat that CSS, so FR3's owner has to carve out the [hidden] rule or decline the change. If FR3 is amended, the [breaking] changeset can merge only once main declares the 0.8.0 minor (spec:AST-017 FR31, FR48); it still declares the patch 0.7.3, which is why check:changesets fails. The code itself needs no changes: both reset.css copies and the manifest hash match main plus this rule, and the new tests fail on the old rule and pass on this one. The pr-rtl failure comes from its vega shard failing to install pnpm before any test ran, so a re-run should clear it.

[Automated review]

The reset's header said every later layer and unlayered style overrides
the reset; the `[hidden]` rule's `display: none !important` is now the one
exception, and the header says so. The rule's comment and the changeset no
longer call an inline `!important` the only override: an `!important` in a
layer declared before `reset` also wins, and the browser spec now checks
that case.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval needs a maintainer to update an existing spec first: spec:AST-080 FR3 says a product's unlayered CSS stays above every Astryx layer, and this rule's display: none !important deliberately makes hidden elements beat that CSS, so FR3's owner has to carve out the [hidden] rule or decline the change. If FR3 is amended, the [breaking] changeset can merge only once main declares the 0.8.0 minor (spec:AST-017 FR31, FR48); it now declares the patch 0.7.4, which is why check:changesets fails. The code itself needs no changes: both reset.css copies and the manifest hash match main plus this rule, and the new tests fail on the old rule and pass on this one.

[Automated review]

@vjeux
vjeux marked this pull request as draft October 29, 2026 22:45
@vjeux
vjeux marked this pull request as ready for review October 30, 2026 00:00
@vjeux
vjeux marked this pull request as draft October 30, 2026 03:37
cixzhang pushed a commit that referenced this pull request Oct 30, 2026
…#8381)

## User impact

**Why:** Keyboard and screen reader users lose their place when a dialog inside an iframe closes: both ways to close it (2 of 2: Escape or a button) send focus to the frame's empty page.

**What:** The dialog now returns focus to the control that opened it, with a ring after a key, none after a click. Picture-in-Picture windows were already fine.

**How to check:** In the "Dialog in a second document" story, open the frame's dialog and press Escape: focus returns to "Open dialog", with its ring.

## Problem and solution fit

What led here: we hit this moving one product onto Astryx, which renders some UI in a second window. Dialog remembers its opener as the page's `document.activeElement`, which for focus inside an iframe is the `<iframe>`. Focusing that `<iframe>` on close moves the frame's focus to its `<body>`.

Options:

- Follow the page's active element into iframes: misses Picture-in-Picture windows, which the page cannot see into.
- Always read the dialog's own document: a page control opening a dialog inside an iframe would lose focus.
- Read the dialog's own document while it has focus, else the page's: covers both. Chosen.

For the ring, Dialog tracks its own document's input, which the page never hears. Skipping its focus call would change the page, where it hides WebKit's ring after a click.

## Expected behavior and authority

`component:Dialog` (current) FR4 and AR2: closing returns focus to the element that opened it. `architecture:interaction-modality` (current) INV1: programmatic focus shows the ring only after keyboard input. Neither is page-only; #7356 fixed this for Popover.

## Smallest restoration

- `Dialog.tsx`: record the opener as above, take the entry direction from its window, return focus with its document's modality.
- Internal utils: `trackInteractionModalityIn(doc)`, counted so the last mounted Dialog removes its listeners; an optional document for `getInteractionModality`; an optional modality for `focusForLastInput`, which checks text fields against their own window. The page's tracker and other callers are unchanged.

No public API, visual or timing change.

## Evidence

- Reproduction before the change: main fails the iframe cases in Chromium and WebKit.
- Result after the change: every case passes.
- Representative unchanged path: the page Dialog passes before and after; the page's modality ignores other documents.
- Regression test or other mutation-sensitive proof: the Testing cases, red without the fix.

## Scope

- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- Unit tests (Vitest), 115 files and 3137 tests: Dialog and every other component that returns focus or reads the last input. New cases cover a control inside an iframe, a control in the page, a text field, and the input listeners going away when the last Dialog unmounts. Each new case fails on the code from before the fix it covers.
- Browser test in Chromium, 10 cases (`DialogSecondDocument.a11y.browser.spec.ts`): the dialog in the page, an iframe and a Picture-in-Picture window, closed with Escape, with a click, and after a text field opened it, plus a page button that opens a dialog in the iframe. All pass. With the code from before the last review round (0d47027), the iframe and Picture-in-Picture text-field cases fail; with main's `Dialog.tsx`, the iframe cases fail.
- The same test in WebKit 26.5: 7 pass, and the 3 Picture-in-Picture cases are skipped, since only Chromium has that window.
- CI finds the test by its file name (#8367), and its routing line also covers its story and the two utilities. Locally, `pnpm test:a11y-contract:pr origin/main` picks it and passes 115 browser tests.
- Typecheck, repo checks, ESLint and Prettier pass. Merged with our open #7732, #8014 and #7524, typecheck and the utility tests (516) pass; #7525, #7527 and #7529 each merge cleanly with this change.
@vjeux vjeux closed this Nov 4, 2026
@cixzhang cixzhang reopened this Nov 4, 2026
@vjeux

vjeux commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Closing this, since spec:AST-080 FR3 keeps a product's unlayered CSS above every Astryx layer. This PR's only change, !important on the reset's [hidden] rule, would put the reset above it. Thanks for the reviews.

@vjeux vjeux closed this Nov 11, 2026

This branch was successfully deployed

1 active deployment
Preview — 8805a9f0 Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants