Repository navigation
Storybook: Add Settings Page design system patterns - #86451
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: -397 B (0%) Total Size: 8.66 MB 📦 View Changed
|
|
I like this a lot. And since we have a slew of React-based settings canvases in the admin already, e.g. Appearance → Fonts and Settings → Connectors, it makes sense to have this guidance. I'd argue we could even benefit from a bit more componentry, such as SectionHeader, ActionList, and SummaryButton, but that's separate. What does this need to land? |
|
I asked AI for feedback and it suggested a third option:
So the title in the example would be On balance I think I actually lean toward showing a |
|
I dabbled with related breadcrumbs recently and came to a similar or adjacent conclusion. WooCommerce has deep settings, so imagine you have something like their shipping settings. Starting from WooCommerce Settings as the starting breadcrumb, you might end up with something like: Settings → Shipping → Shipping zones → Denmark → Flat rate Now the top level Settings page could either show a stack of buttons, of which one of them was a "Shipping" SummaryButton. OR it could show tabs, of which "Shipping" was a tab. Consider the tab angle, here, "Shipping zones" would be a button on that tab page. I experimented with the tab, what I found was:
The behaviour I'm describing there feels totally intuitive to me. What do you think? I know this would be "page navigation" not "tabs" and there's a difference, but I'm calling it tab just for conversation here. |
|
I'm a bit unsure about that; a single navigation action adds two items to the breadcrumb trail which feels a bit unexpected. We can try it though. |
|
Implemented the suggestion and added a screenshot to the Adjacent pages with subpages section. |
|
I genuinely think it works, and is worth starting with here. |
Add templates for settings screens composed from the admin-ui Page, @wordpress/ui components, theme tokens and DataViews: a simple page, adjacent pages, subpages with breadcrumbs, and records that open a subpage, dialog or drawer. Document the manual save model's unsaved changes guard in the Save & Submit pattern. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Adjacent pages now show a "Settings / <page>" breadcrumb, with Settings leading to the first adjacent page since the area has no page of its own. Subpages of an adjacent page pass through it, for example "Settings / Payments / Card payments". Co-authored-by: Cursor <cursoragent@cursor.com>
The navigation already shows which adjacent page is current, so the title stays "Settings" rather than repeating it in a breadcrumb. Subpages keep a trail through their adjacent page, for example "Settings / Payments / Card payments". Co-authored-by: Cursor <cursoragent@cursor.com>
9a04af5 to
92bd059
Compare
ciampo
left a comment
There was a problem hiding this comment.
This looks like a good direction and builds on the existing Page, DataForm, and DataViews patterns. Alongside the inline fixes, could we:
- Align the Destructive Actions and Dialog guidance with these examples, including when a confirmation can open over an editor.
- Note that several UI components used here are still marked "Use with caution", so these templates aren't an unconditional migration recommendation yet.
- Add one failed-save example that preserves the draft, shows an error, and allows retry.
I'm also thinking about a few potential follow-ups:
- an autosave example
- migrating DataForm's remaining Components controls centrally
- applying the agreed save/discard behavior to existing screens.
We should choose the save model and editor type for each workflow, while keeping validation, pending saves, and protection against lost edits consistent.
Following a breadcrumb or subpage row moves focus to the new page's heading, so screen readers announce it. The section navigation keeps focus on the newly current item. Document the guidance. Co-authored-by: Cursor <cursoragent@cursor.com>
Match @wordpress/boot, which moves focus to the new page's Page region when a navigation removes the focused element. Name subpage regions after the current page, since their breadcrumbs replace the title, and update the guidance. Co-authored-by: Cursor <cursoragent@cursor.com>
Explain when to use cards and how to plan headings: card titles are h2s on a page without sections, and h3s under an h2 section heading on the canvas. Add a Settings page with sections example. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Save enabled when fields are invalid and let form submission show the errors, keep editors open when the draft changes during a save, warn before unloading with an open dirty editor, add a failed save example, and move the unsaved changes guidance to the Save and submit pattern (#86725). Co-authored-by: Cursor <cursoragent@cursor.com>
|
@ciampo Thanks for the thorough review! I've pushed changes that address most of it:
Aligning |
Move the unsaved changes guidance from the Settings Page pattern (#86451), use "Discard unsaved changes?" wording in the confirmation, and guard the example with beforeunload. Co-authored-by: Cursor <cursoragent@cursor.com>
Hold navigation until a pending save settles, clear the failed save notice once there's nothing to retry, name each adjacent page's region, drop the disabled Save tooltip, and describe focus restoration as something the example provides until #86701 lands. Co-authored-by: Cursor <cursoragent@cursor.com>
After a key is revoked, focus the next record, the previous one when it was last, or Add API key when the list is empty. Canceling the confirmation still returns focus to Revoke. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
At least in terms of correctness of the examples, code is mostly looking good (one open thread left)
Not sure if anyone else wants to review the actual patterns being proposed, although I trust @jameskoster to have the right context
After revoking a key from the drawer, focus moves to a neighbouring row. The row was found by name, so when two keys shared a name it could pick the row being removed and focus fell to the document body. Mark each row with its record ID and match on that instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
I took another look at the patterns themselves. They make sense to me as starting points. Experiments already groups settings in cards, Post List offers both a full editor and a Quick Edit modal, and Widget Settings uses a drawer. Experiments · Post List · Widget Settings
Re. breadcrumbs, I guess we should pick an approach and potentially re-evaluate as we get more feedback
The duplicate-name revoke case works for me now too. I'd coordinate the save wording with #86725 so the two guides agree on when to use manual save.
| // on top of the record that was just saved. | ||
| const latest = draftRef.current; | ||
| if ( JSON.stringify( latest ) === JSON.stringify( submitted ) ) { | ||
| setIsOpen( false ); |
There was a problem hiding this comment.
With Access filtered to "Read only", I opened Analytics dashboard, changed Access to "Read and write", and saved. The row disappeared and keyboard focus landed on the document body in both the dialog and the drawer. Could we focus a remaining row, or the "Add API key" button when the filtered table is empty?
There was a problem hiding this comment.
Fixed in 1cfa687. Before saving, the editor captures where focus should go if the row leaves the table: the next row, the previous one when it was last, or "Add API key" when the filtered table is empty. If the save leaves the row in place, focus returns to whatever opened the editor as before. The lookup is shared with revoke, and both the dialog and the drawer use it.
There was a problem hiding this comment.
Non-blocking follow-up. I filtered to one key, renamed it so it left the results, and edited Notes while Save was busy. Saving the notes then sent focus to the document body in both the dialog and drawer. Could we keep the first save's focus target until the editor closes?
There was a problem hiding this comment.
Fixed in f79ee1a. A later save only replaces the focus target when it finds the row in the table, so the first save's target survives until the editor closes. There was a second cause too: Base UI also calls the finalFocus function on re-renders while the overlay is open, and ours cleared the target the first time it was called. It now only reads the target, and opening the editor clears it. Your steps now end on the next row, or on "Add API key" when no rows remain, in both the dialog and the drawer.
- Make the record name searchable. - Keep focus in the table when a save moves a record out of the filtered view, in both the dialog and the drawer. - Warn before reloading while a record save is in progress. - Use an unstyled Link for subpage rows, as admin UI does for its navigation links. - Align the saving guidance with Save & Submit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. The inline points are addressed in 1cfa687. On the save wording: the Saving section now gives the same reason as #86725 for choosing manual save (settings fields often depend on each other and should apply together), uses the same autosave example (the block editor's Preferences modal), and links to its "Choose one save model per surface" section rather than restating it. The two guides already agreed on the rest, including the discard dialog copy. Re. breadcrumbs, agreed: let's keep the current approach and revisit as feedback comes in. |
| const key = keys.find( ( { id } ) => path === `/keys/${ id }` ); | ||
|
|
||
| if ( ! key ) { | ||
| return <KeysPage keys={ keys } />; |
There was a problem hiding this comment.
Non-blocking. I searched for "Mobile app", opened it, and followed the "API keys" breadcrumb. The search cleared and all four rows came back. Could we keep the table view when returning so people can work through their filtered results?
There was a problem hiding this comment.
Fixed in f79ee1a. KeysTable can now take its view and onChangeView from outside, and the subpage example holds the view above its routes, so following the "API keys" breadcrumb brings back the search, filters and page as you left them. The guide now says to keep the view somewhere that outlives the table, and notes that real screens usually keep it in the URL or user preferences.
|
|
||
| const save = async () => { | ||
| setIsSaving( true ); | ||
| setHasFailed( false ); |
There was a problem hiding this comment.
Non-blocking. Pressing Enter on "Try again" removes the focused button and leaves focus on the document body, even after the retry succeeds. Could a valid retry move focus to "Save changes" before the notice disappears?
There was a problem hiding this comment.
Fixed in f79ee1a. When a retry passes validation, focus moves to "Save changes" before the notice goes; the button stays focusable while busy or disabled. A retry with an invalid field still sends focus to that field. The "When a save fails" guidance now says the same.
- Move focus to Save changes when a valid retry removes the failed save notice and its Try again button. - Keep the records table's search, filters and page when returning from a record's subpage. - Keep the first save's focus target when a later save follows edits made while saving, and only read it in finalFocus, which Base UI also calls on re-renders while the overlay is open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the continued reviews @ciampo ❤️ |
|
In the future I guess it would make sense to add these stories one at a time 😅 |
|
Anything left here @ciampo? |
There was a problem hiding this comment.
I rechecked the two-save case in both editors, retry focus, and returning to a filtered table. All 3 work for me now!
One small docs update: #86701 has merged, so could we update the focus paragraph and router comment to say Boot now handles this on trunk?
Otherwise LGTM 🚀
|
Another optional micro-nit: The |
|
I think I'llleave that to #86921. I understand the guidance here will be picked up automatically once both are PR's are in. |
@jameskoster just to make sure, is this change being implemented anywhere? I'm struggling to keep track of al the parallel Storybook-related PRs 😅 |
Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>

What?
Adds a "Design System / Patterns / Settings Page" docs page to Storybook with templates for settings screens, composed from the admin-ui
Page,@wordpress/uicomponents,@wordpress/themetokens and DataViews:Pagenavigation, each with its own draft and Save.Badge, each opening a subpage with breadcrumbs and the same badge in the header.The templates are starting points, not prescriptions. Not every settings page has to follow these exact patterns, and the docs page says so too. They show one well-composed way to build each kind of screen, to adapt or depart from where a product's settings call for something different.
It also extends the Save & Submit pattern's "Unsaved changes on exit" section with guidance the templates follow.
Why?
Settings screens are among the most common admin surfaces, and there's no reference for composing them from the new design system packages. These templates give a starting point that follows the Save & Submit and Destructive Actions patterns, so each settings screen doesn't have to rediscover the same decisions.
How?
Each template is a story with its source shown via "Show code". Shared helpers live alongside them in
storybook/stories/design-system/patterns/settings-page/:Pageheader, disabled when there's nothing to save, with a snackbar on success. On/off settings use checkboxes rather than toggles, since nothing applies until Save.AlertDialog, and reloading uses the browser'sbeforeunloadwarning. The in-canvas TanStack router uses a small memory-history wrapper, because memory history ignores blockers.ulnamed by the card heading, with each link named after its destination and the status badge connected througharia-describedby.--wpds-dimension-surface-width-xl, and records tables at--wpds-dimension-surface-width-2xl.Testing Instructions
npm run storybook:devand open Design System / Patterns / Settings Page.Testing Instructions for Keyboard
Screenshots or screencast
Simple settings page
Adjacent settings pages
Settings subpages
Adjacent pages with subpages
Records with subpages
Records dialog
Records drawer
Use of AI Tools
This PR was authored with Cursor (Claude), working from my direction and feedback across many iterations. I've reviewed the templates and guidance in Storybook.