Skip to content

docs(useListFocus): add a recent files example block - #9577

Merged
cixzhang merged 2 commits into
meta:mainfrom
kyu-rong:docs/useListFocus-example
Nov 2, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
kyu-rong:docs/useListFocus-example

Conversation

@kyu-rong

@kyu-rong kyu-rong commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Reader impact

A builder reading the useListFocus docs has no runnable example of the hook. After this change the hook's page shows a "Recent files" list of buttons that the hook drives from the keyboard, and astryx template useListFocusHookUsage <path> copies it.

Source of truth

  • useListFocus and its HookDoc (packages/core/src/hooks/useListFocus.ts, useListFocus.doc.mjs).
  • architecture:knowledge-contracts INV28.

Correction

Adds a "Recent files" block (exampleFor: 'useListFocus'): four Buttons in a VStack wired to the hook's listRef, handleKeyDown and handleFocus.

  • orientation, wrap and hasHomeEnd are the defaults, but I pass them so each behavior maps to an option a reader can see.
  • The container is role="toolbar", the WAI-ARIA pattern for controls that arrow keys move through, which the hook doc names. A plain labelled group is a one-line change if preferred.
  • A click does not move the Tab stop. That is the hook's current behavior, and this PR does not change it.

Changes

  • New block packages/cli/assets/templates/blocks/components/Hooks/useListFocusHookUsage.tsx and .doc.mjs.
  • New test packages/cli/api/template/use-list-focus-hook-usage.test.tsx. It sits outside assets/templates/, so the template viewer does not load it as a template.
  • Changeset .changeset/use-list-focus-recent-files-example.md (@astryxdesign/cli patch, [docs]).
  • Scope:
    • This PR changes documentation only, or names every necessary generated artifact. The generated artifacts are the new block's route in internal/shadcn-registry/routes.lock.json and its sandbox route in apps/sandbox/scripts/next-export-routes.json.
    • Runtime, API, visual, and policy changes were removed or split.
    • Public text and artifacts contain no internal Meta context.

Test Plan

  • Docsite (Chromium): one Tab stop; arrows move and wrap, Home/End jump to the ends; Tab out and back returns to the last keyboard-focused row.
  • use-list-focus-hook-usage.test.tsx: Tab stop, arrows with wrap, Home/End; all tests fail with the hook replaced by a no-op, and each option's test fails with that option turned off.
  • Route manifest, tree.test.mjs, template and registry suites, docsite example coverage, typecheck, lint and changeset coverage pass.

Related Issues

Closes #9479

@vercel

vercel Bot commented Nov 2, 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 Nov 2, 2026 7:59pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 2, 2026, 8:03 PM UTC

@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 Nov 2, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b093ef1

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 3.30 MB packed (+453 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 2 rows, core 23 rows; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

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

Thanks, this looks ready to merge. The Recent files block demonstrates useListFocus the way architecture:knowledge-contracts INV28 asks: the single tab stop, arrow keys, Home/End and wrapping all come from the hook, the new test fails when any of those options is removed, and the docs build shows the block on the hook's page. CI has not run yet because outside-contributor pull requests wait for a maintainer's ci:run label, so the remaining step is a green CI run.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 2, 2026
@cixzhang cixzhang closed this Nov 2, 2026
@cixzhang cixzhang reopened this Nov 2, 2026
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 2, 2026
@github-actions github-actions Bot added the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 2, 2026

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

Thanks, this is ready to merge. The Recent files block demonstrates useListFocus the way architecture:knowledge-contracts INV28 asks: the single tab stop, arrow keys, Home/End and wrapping all come from the hook, the new test fails when the hook or any of those options is removed, and the merged route entries match the generator. The remaining step is for the CI checks still running to finish green.

[Automated review]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 2, 2026
@cixzhang
cixzhang merged commit e0548a6 into meta:main Nov 2, 2026
60 checks passed

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(useListFocus): add a minimal live example

2 participants