Skip to content

Expose a stable open-state anchor (role/data-*) on HoverCard & Tooltip layers for testability #3240

Open

Description

@tangentlin

Summary

HoverCard and Tooltip render their floating layer as a body-level element with popover="manual"/"auto" and no role, no data-testid, and no open-state attribute. The only programmatic link from the trigger to the layer is the injected aria-describedby → layer id. This makes the open/closed state and the layer itself hard to anchor for UI test tooling that resolves elements via stable selectors (roles, data-*, accessible names) rather than build-time-hashed StyleX classes.

Current DOM (observed, v0.1.1)

<!-- trigger -->
<button aria-describedby="_r_k_">Hover me</button>
<!-- layer (body-level popover) -->
<div id="_r_k_" popover="manual" class="astryx-hovercard …">
  <div class="astryx-hovercard …"><div>…content…</div></div>
</div>
  • Tooltip is identical except the layer class is astryx-tooltip and its content is a bare text <div>.
  • The layer carries no role (not tooltip, not dialog) and no attribute reflecting open/closed.

Why it matters

  • Open/closed cannot be distinguished from attributes — only via the native Popover API's visibility, which environments without a layout/Popover engine (e.g. jsdom) cannot observe. This forces all open-state coverage to full-browser E2E.
  • Anchoring the layer requires either the unstable StyleX-hashed class or following aria-describedby to the id — workable for a single instance, fragile for many.

Requested change (any one would help, in priority order)

  1. Add role="tooltip" to the Tooltip layer (and an appropriate role to the HoverCard layer), per the ARIA APG.
  2. Reflect open state with a stable attribute on the trigger and/or layer (e.g. aria-expanded on the trigger, or data-state="open|closed" on the layer) — mirroring the pattern Popover already uses (aria-expanded/aria-controls).
  3. Forward a data-testid from props onto the layer.

Workaround we ship today

We ship a best-effort v1 HoverCardDriver/TooltipDriver (in @atomic-testing/component-driver-astryx) that anchors on the trigger and resolves the layer via aria-describedby → id, reading content in both states; the open transition is documented as E2E-only. Any of the above would let us promote these from best-effort to first-class.

Activity

  1. Daniel15 commented on Jun 29, 2026

    @Daniel15
    Member

    We should definitely add ARIA roles here. I'd personally try to avoid data-testid though.

  2. added this to the 0.1.2 milestone on Jun 29, 2026
  3. cixzhang commented on Jun 29, 2026

    @cixzhang
    Contributor

    Partial progress: the priority ask (option 1) shipped in v0.1.2 via #3243 — the Tooltip layer now renders role="tooltip", giving it a stable, non-hashed selector and completing the ARIA tooltip pattern.

    Remaining (kept open, moved to the 0.1.3 milestone):

    • HoverCard role — no unambiguous ARIA role for a hover-triggered rich card (dialog implies modal), so this needs a design call.
    • data-testid forwarding — straightforward follow-up; note @Daniel15's preference to avoid data-testid in favor of ARIA/state attributes.
  4. modified the milestones: 0.1.2, 0.1.3 on Jun 29, 2026
  5. Daniel15 commented on Jun 30, 2026

    @Daniel15
    Member

    HoverCard role — no unambiguous ARIA role for a hover-triggered rich card (dialog implies modal),

    The ARIA dialog role allows for non-modal dialogs.

  6. added
    enhancement
    component
    on Jun 30, 2026
  7. cixzhang commented on Jul 1, 2026

    @cixzhang
    Contributor

    Partial progress: #3243 shipped role="tooltip" on the Tooltip layer (the priority ask). Remaining: HoverCard role, data-state="open|closed", and data-testid forwarding are deferred as separate follow-ups.

  8. modified the milestones: 0.1.3, 0.1.4, 0.1.5 on Jul 4, 2026
  9. cixzhang commented on Jul 8, 2026

    @cixzhang
    Contributor

    Reviewing this issue --

    First off, https://w3c.github.io/aria/#dialog for dialog role spec. Seems like there's a separate aria-modal for modal-specific dialogs.

    Dialogs are often used to prompt the user to enter or respond to information, or can represent content related to understanding or modifying the content of the primary application window.

    The second part seems to fit the description for hovercard. It's imperfect because all the following descriptions of what a dialog SHOULD be fit the hovercard a bit less. HoverCard is a hover activated window with supplemental content related to content in the primary application window. I suppose dialog has no requirements about it's activation so might be okay to use it for now.

    • data-state="open"|"closed": This seems like a nice to have for testing purposes but not an accessibility concern. Probably aria-expanded/controls would be better, but we would need to apply that to the trigger.
    • aria-expanded/aria-controls is likely better but gives the impression that this is a toggle pattern and activates on click/press/enter which is not always the case for hovercards.

    I think I'm going to want to test some options with VO to see how the experience is.

  10. added
    needs-scoping
    on Jul 8, 2026
  11. modified the milestones: 0.1.5, 0.1.7 on Jul 15, 2026
  12. ejhammond commented on Jul 15, 2026

    @ejhammond
    Contributor

    Partially shipped as of v0.1.6: the role="tooltip" anchor on the Tooltip layer landed (#3243). The stable open-state anchor (data-state on the HoverCard/Tooltip layers) is still outstanding — the earlier attempt (#3537) was closed unmerged. Moving this to the 0.1.7 milestone to track the remaining open-state work.

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

    componentenhancementneeds-scoping

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions