Repository navigation
UI: Add Item - #86676
UI: Add Item#86676jasmussen wants to merge 26 commits into
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: +7.03 kB (+0.08%) Total Size: 8.73 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Navigates the list via UP/DOWN arrow keys from action buttons in
|
|
Before moving to implementation, there are a few things IMO we should discuss: Do we want / need an Asking because in the past we received feedback about it basically being a glorified list with rounded borders, and I want to make sure we create the right / useful abstractions for our evolved needs; we don't necessarily need to match For example, what's the difference between "item group items" and card? Especially for a single-item itemgroup ? Maybe there is potential for integrating this into Card APIs instead? Also, this feels definitely related to the Settings patterns work, and I feel like it would make sense to agree on components / patterns that we want to endorse in those setting pages before implementing a new component in isolation. (cc @WordPress/gutenberg-components ) Also:
This shouldn't be the case, is it just a hallucination or was your agent looking at an old version of the component? |
|
Very valid, and certainly one of the questions I want to press with this PR. For me the answer is yes, given how many places we have bespoke implementations of roughly the same thing, but I'll add question labels to make it clear I like that question. And yes, the emotion stuff could be a hallucination. |
|
We can potentially take inspiration from
|
|
Related, as I find, this PR closes #64445! |
|
OK, based on the discussion here and the shadcn precedent, I took another stab. I have a local version that is composition-based rather than prop-based, still unpushed. You can try it on the prototype, through the toggle at the top. The output is identical, but the implementation is not. Instead of one ItemGroup with a lot of props, you compose the row yourself out of named parts. A common row goes from one line of React to six. Both versions are compound components, so “exposing the insides” is not foreign to the system since Card, Menu and Tabs already work this way. Trade-offs:
We could decide to accept the Button composition risk, and we could revisit whether Card should clip at all. The benefits of the composition-based version:
So it's more code to maintain, more verbose to use, but more flexible, and each part is simpler on its own. It also seems like the most direct answer to WordPress/gutenberg#64445. I’d rather you all evaluate that than me. Worth noting that neither version is a candidate for the drag-reordering also mentioned in WordPress/gutenberg#64445, which seems separate, but worth flagging it in case you disagree. |
|
I like the move to named parts. I'd take it one step further and make A single item should work on its own. For a collection, I'd wrap any mix of those three in By default I'd join the entries in one frame with dividers. I put those compositions side by side in the interactive prototype. There's a two-column example there too. I'd settle the row and group APIs first and explore layout options separately if we have a use case for them. |
|
Good feedback. I rebuilt locally around your latest prototype and have a model ready to push, which uses this markup: You can see the latest model on the prototype, still under the Item tab. One of the consequences worth discussing is the bare item at the bottom:
Since the card adds the border, the inner item can now sit alone, "bare", on the canvas. How do we feel about this? Beyond any feedback, I'd suggest if we do go this direction, for me it would be worth looking at what we can do with the padding. It's the padding that makes it look off. |
- Bound the meta column to a quarter of the row and let its value wrap, so a long URL no longer pushes the actions out of the row. - Let rows inherit the density of their group through CSS, so the group context carries only the variant.
- Let clicks in the space between two actions reach the row control. - Warn when an Item.LinkRow has neither an href nor a render prop. - Track the actions and the chevron in a ref, so mounting actions no longer renders the row again. - Document one Item.Description and one Item.Meta per row. - Share the render prop helper of Breadcrumb, now in utils.
- Set the ids of the label, description and meta only in link and button rows, which reference them. A static row keeps the id the consumer passes, so a control in Item.Actions can reference its label. - Treat an empty aria-labelledby as absent. - Style a row from its own control, not from a row nested in its actions. - Remove width and height from the Item.Chevron types, which Icon ignores, and assert that Item.Media is hidden.
…label - Treat a whitespace-only aria-label or aria-labelledby as absent, so the row control keeps the name from its label. - Keep an aria-hidden the consumer sets on the label of a static row. - Document that naming props go on Item.LinkRow, not on its render element, so they combine with the references of the row. - Provide the group variant directly as the group context.
- Hide a group, a static row and actions that have the hidden attribute, which their own display would otherwise override. - Show the label of a disabled row in GrayText in forced colors. - Pass the naming props of link and button rows straight to the row. - Name the list in the Item.Group example.
- Remove the hidden rule for the group, static rows and actions. Like other @wordpress/ui components, Item sets its own display, so consumers hide a row or a part by not rendering it. The usage guidelines now say so. - Use the interactive foreground token for the label of link and button rows. - Reuse the Detached story in the usage guidelines.
- Carry the label color through the heading defense, so a label that renders as a heading follows the interactive and disabled colors. - Leave out the line above a group that is flush with the top of a card, where the border of the card already draws one. Card.FullBleed now says whether it is flush with the top edge.
…gelog In a narrow row, the grid gave the meta its full quarter before the label, so the label broke mid-word. The label now takes at least as much as the meta can. The layout test uses a control of a fixed width, so it no longer depends on the fonts of the platform. Also move the Unreleased sections of the changelog into the order that the changelog validation expects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Stop supporting a label rendered as a heading in link and button rows. The label is hidden from assistive technology there, so the heading would not reach it. Document that, and drop the heading color bridge and its test. - Say that a row needs a label unless it has an explicit name, and that a detached group goes in `Card.Content` without `Card.FullBleed`. - Check the exact message in the warning tests. - Remove a duplicated comment and a stray blank line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A floor on the label column could push wide actions out of a narrow row, and squeezed the meta to a sliver. The grid cannot make the meta yield before the label without one of those regressions, so the label column is flexible again. The layout tests now check what the row keeps on any platform: the meta stays within a quarter of the row, and the actions stay inside it, also next to media. Also say that an explicit name replaces the label, so it should include the visible label text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show a row that keeps its other actions in a menu, and a collapsible card with two groups, each named by its own heading. Also say that `Item.Media` holds no control, so that a drag handle for sorting can come later as a part of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ard stories Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the shipping, payment gateway and billing examples with general settings: users, notifications, features, content and export. Payments stays as one of the connected services. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bb496a9 to
69ed0f0
Compare
* Components: Alias legacy Item imports as WCItem Rename every `__experimentalItem` import from `@wordpress/components` to `WCItem`, ahead of `@wordpress/ui` exporting an `Item` component (WordPress#86676). The `WCItem` entry in `tools/eslint/components-import-aliases.mjs` lands with that export: the alias test rejects an alias for a name that does not collide with a `@wordpress/ui` export yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add DataViews changelog entry for legacy Item aliases Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
|
Hey @jasmussen, great work on this and hoping to use it soon! In the prototype the icon on the left and the chevron/actions on the right align to the top rather than the middle of the row. With one-line descriptions, like most of these, it feels a little off balance to me. Any particular reason to have it top-aligned?
|
|
@poligilad-auto I'm not sure how up to date the prototypes are. This Storybook link reflects the code changes in this PR, and the vertical alignment is centered:
|
|
Separately, is there anything blocking this PR from shipping? I'd like to wrap this first iteration up soon and iterate as needed. |
|
Yep, Marco took over the PR so the prototypes are now just that, initial prototype explorations, so Marco's link is the one to review. And on my end, this feels pretty good. Curious what @jameskoster thinks. |
|
Ohhh it looks so good! I love it, thank you @jasmussen and @ciampo !!! i'll incorporate this into the settings prototype 😊 |







Closes #64445. See #34709 and #86451.
What?
Adds the
Itemfamily to@wordpress/ui: rows for lists of items and settings, composed from parts, withItem.Groupto list them.Why?
Several screens build this row by hand, each with its own markup and accessibility story: the site editor sidebar, the font library, the block inspector's color rows, and the settings-page patterns from #86451.
__experimentalItemGrouphas no@wordpress/uisuccessor, and it only provides the container.How?
Item.LinkRow: the whole row is a link.Item.ButtonRow: the whole row is a button.Item.ContentRow: only the controls inItem.Actionsare interactive.Item.Media,Item.Label,Item.Description,Item.Meta,Item.ChevronandItem.Actions.Item.Actionssit above it, so nothing interactive is nested. This is the technique the DataViews list layout uses. The row control takes its name fromItem.Label, and its description fromItem.DescriptionandItem.Meta.Item.Grouprenders aul, and each row inside it anli.variant="joined"(the default) draws one frame with a line between rows.variant="detached"gives each row its own frame and keeps one list.Card.FullBleedthe card is the frame: the group keeps only a line under the card header, and none at the top edge of the card. Its first and last rows follow the corners of the card, so the focus ring is not clipped.Item.LinkRowacceptsopenInNewTabandtarget, asLinkandMenu.LinkItemdo.Item.Chevronthen shows the new-tab arrow, and the link name gets "(opens in a new tab)".Item.Metatakes at most a quarter of the row.Outside
packages/ui, this PR only adds the__experimentalItem: 'WCItem'ESLint import alias intools/eslint/components-import-aliases.mjs. #87488 already renamed the legacy__experimentalItemimports toWCItem, so they do not collide with the new export.Example
Decisions from the review thread
ItemGroup, following shadcn/ui'sItem.Item.Actionsshows no chevron.Item.Chevronwarns in development when both are present.Item.Actionsdoes not change its children. Each control needs a name that includes its row, such as "Reset background color".Item.Actions, including the trigger of an infotip.Item.Media,Item.Label,Item.DescriptionandItem.Metastay static.MenuinItem.Actions, as the With Overflow Menu story shows.separatedbecamevariant="detached". The usage guidelines explain when to use joined rows, detached rows or separate groups.Item.Mediais a plain slot, with no tile behind it, because it also holds swatches, logos and thumbnails.Testing Instructions
npm run storybook:devand open Components → @wordpress-ui → Item.Testing Instructions for Keyboard
Screenshots or screencast
This PR adds a new component, so there is no "before" in trunk. All screenshots come from a local
storybook/buildofe7a30e3840c, and the collapsible card one frombb496a9da2f, before the rebase onto trunk. The rebase leaves the component code unchanged.Stories
Usage guidelines examples
Focus and hover
Right-to-left, dark theme, and WordPress global CSS
Storybook's RTL mode keeps the English text, so the browser moves its punctuation and the number in the badge.
TODO / Follow-ups
Item.Actionsavoid this in narrow containers such as the editor sidebar.ItemGroup#64445 asks for ("Has re-ordering") and Components: add sortable, multi-selectable list #66413 explores. The current API leaves room for it without breaking changes:Item.Actionsdoes.Item.Mediais now documented as holding no control, so nobody puts a handle there in the meantime.Item.Group, or a separate sortable group. The list keeps itsulandlisemantics.hiddensupport across@wordpress/ui. Components set their owndisplay, which overrides the attribute, so for now the usage guidelines tell consumers to hide a row by not rendering it.Earlier prop-based prototype (screenshots from the first version of this PR)
The prototype link now shows a later build that uses the current API.
Use of AI Tools
Most of this branch was written with AI assistance (Claude) and reviewed by people in the thread. The first version was written with Claude Opus. The current API and the fixes from review were written with Claude Code, and each round was checked by an independent AI reviewer (GPT 6.2 Astra, then Claude Opus 5.5 for the final round), with tests added for every confirmed defect.
🤖 Generated with Claude Code