Skip to content

feat(core): reflect layer open state via data-state on the popover element - #3537

Closed
arham766 wants to merge 2 commits into
meta:mainfrom
arham766:feat/layer-data-state
Closed

arham766 wants to merge 2 commits into
meta:mainfrom
arham766:feat/layer-data-state

Conversation

@arham766

@arham766 arham766 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the data-state="open|closed" follow-up deferred from #3240 (option 2 in the issue; role="tooltip" already shipped in #3243).

Every layer rendered through useLayer — Tooltip, HoverCard, Popover, ContextMenu, Tokenizer overflow, keyboard hints — now reflects its open state as a data-state attribute on the popover container, in both context and fixed modes. Values mirror the Popover API's own ToggleEvent.newState naming (open/closed).

Why on useLayer rather than per component: the attribute stays consistent across every current and future layer consumer, and browser-initiated closes (light dismiss / popover stack eviction) already flow back through the existing toggle-event reconciliation, so the attribute stays in sync with the DOM for free.

Per @Daniel15's note in the issue, this deliberately does not add data-testid forwarding.

Test plan

  • New assertions: Tooltip flips closed → open → closed across hover show/hide; HoverCard flips closed → open (both via getByRole + toHaveAttribute, running in jsdom — which is exactly the environment the issue says cannot observe :popover-open)
  • All layer-consumer suites pass: Tooltip, HoverCard, Popover, ContextMenu, Tokenizer, Carousel, Layer (148 tests) + hooks (116 tests)
  • pnpm -F @astryxdesign/core run typecheck and eslint on touched files — clean

arham766 added 2 commits July 3, 2026 22:08
The anatomy claimed a scroll-driven scale effect that does not exist,
and hasButtons was described as hover-triggered and desktop-only. The
buttons are actually driven by per-edge overflow: each appears when the
content can scroll in that direction. Descriptions now mirror the
component JSDoc. The docsZh usage block was still in English; translate
it in the same style as the other component translations.
…ement

Layers rendered through useLayer expose data-state="open|closed" on
the popover container, mirroring the Popover API toggle-state naming.
Open/closed can now be asserted from stable attributes in environments
without a layout/Popover engine (jsdom), instead of only via
:popover-open in full browsers.

Covers the data-state follow-up deferred from meta#3240 (role="tooltip"
shipped in meta#3243).
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

@arham766 is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 4, 2026
@arham766
arham766 marked this pull request as ready for review July 4, 2026 05:15

@cixzhang cixzhang 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.

Hey @arham766, thanks for working on this. Unfortunately I had to mark the main issue as "needs scoping" since I want to explore options for HoverCard accessibility + testing a bit more. The carousel doc updates here seem okay though. Mind breaking out the PR just for that?

@arham766

arham766 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Makes sense — happy to wait for the re-scope on the HoverCard side.

Good news on the carousel docs: they're already broken out — this branch was stacked on #3532, and the Carousel.doc.mjs + changeset changes here are byte-identical to that PR. So #3532 is exactly the docs-only PR you're describing, ready for review as-is.

Closing this one; I'll pick the data-state work back up once the issue is re-scoped.

@arham766 arham766 closed this Jul 8, 2026
@cixzhang cixzhang added area:core needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 8, 2026
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:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants