Skip to content

feat(treelist): reveal endContent on hover/focus via endContentReveal - #4538

Closed
freddymeta wants to merge 1 commit into
mainfrom
feat/treelist-endcontent-reveal
Closed

freddymeta wants to merge 1 commit into
mainfrom
feat/treelist-endcontent-reveal

Conversation

@freddymeta

Copy link
Copy Markdown
Contributor

What

Adds a tree-level endContentReveal prop to TreeList — 'always' | 'hover', default 'always' (non-breaking).

With endContentReveal="hover", each row's endContent is hidden at rest and revealed when the row is hovered or focused, and stays visible on touch. This is for secondary row actions (e.g. a delete button) that would otherwise clutter the tree at rest.

<TreeList
  endContentReveal="hover"
  items={[
    { id: 'report', label: 'report.pdf', onClick: open,
      endContent: <Button isIconOnly label="Delete report.pdf" icon={<Icon icon={TrashIcon} />} onClick={remove} /> },
  ]}
/>

Is this accessible? Yes — by construction

Hover-to-reveal is only an a11y problem when done naively. This implementation avoids every failure mode:

  • Keyboard: revealed on :focus-within, so tabbing into the row (or into the action itself) shows it. Not pointer-only.
  • Never unmounted: opacity-only — never display:none/visibility:hidden, which would drop the control from the tab order and a11y tree. The action stays mounted and focusable, so it can receive the focus that triggers its own reveal.
  • Touch: stays visible on @media (any-pointer: coarse), so the action is never gated behind an unavailable hover.
  • Pointer: the hover branch is guarded by @media (hover: hover).
  • Motion: honors prefers-reduced-motion (0s transition).

Approach

Mirrors the already-shipped, reviewed Thumbnail showRemoveOn="hover" pattern exactly:

  • CSS-driven via stylex.when.ancestor(':hover' / ':focus-within', treeItemScope).
  • A scoped treeItemScope marker (stylex.defineMarker()) is applied per row, so a nested tree's rows react to their own hover/focus — not an ancestor row's, and not an outer container's.

Changes

  • endContentReveal prop on TreeList (threaded to TreeListItem); default 'always'.
  • New treeList.markers.stylex.ts scope marker.
  • TreeListEndContentReveal type, exported from the package.
  • Reveal style on the endContent span; marker on the row (only when hover).
  • Tests: mounted/focusable contract in hover mode + class-application + default behavior.
  • Docs: prop across all three doc variants, a best-practice note, and a Hover Actions showcase block.
  • Changeset (patch).

Testing

  • TreeList suite: 69 passed (incl. 3 new). Showcase manifest tests: 12 passed.
  • typecheck:docs, typecheck:template-docs, check-sync, sync-exports --check, token-docs --check, changeset check, eslint — all green.
  • Verified emitted CSS: opacity:0 at rest; opacity:1 under :hover * (guarded by @media (hover: hover)), :focus-within *, and @media (any-pointer: coarse).

Add a tree-level `endContentReveal` prop (`'always' | 'hover'`, default
`'always'`, non-breaking) so each row's endContent can stay hidden until
the row is hovered or focused — useful for secondary row actions like a
delete button that would otherwise add visual noise at rest.

The reveal mirrors Thumbnail's proven `showRemoveOn="hover"` pattern:

- CSS-driven via `stylex.when.ancestor(:hover / :focus-within, marker)`,
  keyed to each row through a scoped `treeItemScope` marker so a nested
  tree's rows react to their own hover/focus, never an ancestor row's.
- Accessible by construction: opacity-only (never display/visibility),
  so the content — and any focusable action inside it — stays mounted
  and in the tab order; tabbing to it triggers the row's :focus-within
  reveal. The hover branch is guarded by `@media (hover: hover)` and the
  content stays visible on `any-pointer: coarse` (touch), so the action
  is never gated behind an unavailable hover. Honors
  `prefers-reduced-motion`.

Includes tests (mounted/focusable contract + class application), the
`endContentReveal` prop across all doc variants, a best-practice note,
a Hover Actions showcase block, and a changeset.
@vercel

vercel Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Jul 30, 2026 6:46am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 30, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

TreeList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 809 -
Complexity N/A Very High (80) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@freddymeta

Copy link
Copy Markdown
Contributor Author

Closing — no longer necessary.

@freddymeta freddymeta closed this Jul 31, 2026
@github-actions
github-actions Bot deleted the feat/treelist-endcontent-reveal branch July 31, 2026 07:03

This branch was successfully deployed

1 active deployment
Preview — 6f98716c Deployed Jul 30, 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. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant