Skip to content

DataViews: support true hierarchical nesting with expand/collapse #80360

Open

Description

@verofasulo

What problem does this address?

DataViews can currently only represent hierarchy as visual indentation — child items are prefixed with em-dashes (—), mimicking WP_List_Table. This isn't real nesting:

  • There's no true expand/collapse tree for nested items (e.g. category → subcategory → sub-subcategory).
  • At scale, a flat list of hundreds of nested items is unmanageable — everything is always visible, with no way to focus on a single branch.
  • Indentation alone (the "em-dash" faking) signals depth but doesn't let you collapse a parent, and it degrades across pagination, sorting, and search.

What is your proposed solution?

Introduce a genuine hierarchical tree in DataViews (table layout only), with a disclosure chevron on each parent row to expand/collapse its children, so deep structures can be navigated without rendering everything flat. Below, I break down the proposal.

Prototype

https://hierarchical-nesting.vercel.app/

I'm experimenting with Categories to see how the pattern works and scales in more complex scenarios like taxonomies. The prototype only shows a proposal for the parent–child relationship. You can switch between the different options outlined below by clicking the "States" pill at the bottom left.

Affordance (expand/collapse control)

Hierarchical.nesting.-.Affordance.mov

Chevron on the left: common pattern across products, but it offsets the whole table. If manual reordering is added in the near future (which is needed), the left side could get too crowded with actions. If we go this direction, one idea proposed by @JanaMW27 and @fcoveram) is a "master" chevron in the header that expands/collapses all elements at once.

Chevron after the title: either inside the count badge or standalone. Better for table alignment, but there are concerns about making the badge interactive, since that's not an established pattern. If child counts can't be detected, the badge goes away and we fall back to a standalone chevron after the title. Note that titleField in DataViews isn't required, so the chevron/badge would attach to the first available field.

Sorting

Sort within each level: top-level items are sorted together, and each parent's children are sorted within that parent. A flat, global sort would separate children from their parents and break the tree.

Pagination

Drop the items-per-page setting, since it's a flat-list concept that doesn't map to a tree. That's separate from pagination as a mechanism: we still need a per-level "load more" so a single parent with many children — or a very large top level — stays bounded.

Counts & totals

Need to confirm whether the APIs can reliably identify the number of children. If that's a promise the lazy data layer can't keep, we should drop the counts.

Search

Search behaves as a distinct view: a flat result set where each match carries its ancestor path in breadcrumb form, so users can see where an item lives without rendering the full tree. It spans all pages, not just currently visible items.

We also explored rendering the full tree in the results, but ruled it out — it forces constant reloading and the UX gets very complex for little benefit. That narrows the options to three, all flat and breadcrumb-based:

  • Two lines: match on top, path underneath.
  • Ancestors before, one line: full trail, match at the end.
  • Ancestors after, one line: match first, path trailing.
Hierarchical.nesting.-.Search.mov

On smaller screens, the two-line option is the only viable approach.

Image

Open questions

  • Affordance: chevron on the left vs. after the title, and whether the count badge should be interactive — plus whether to add a "master" expand/collapse chevron in the header.
  • Counts & totals: can the APIs reliably return the number of children?
  • Search result display: which breadcrumb layout — two-line, ancestors-before, or ancestors-after? (Two-line is the only one viable on small screens.)
  • Anything else?

Related issues

  • #72654 — Add expanding hierarchical items to DataViews
  • #74072 — DataViews: visualize hierarchical data

@jasmussen @fcoveram @ntsekouras @oandregal @gigitux @tyxla

Activity

  1. jasmussen commented on Jul 20, 2026

    @jasmussen
    Contributor

    This is wonderful work, I fully endorse it. Thank you for the powerful contribution.

    I'm not personalyl convinced about the child counts, and I do think technically it might cause performance issues on sites with thousands of pages, but that's a soft nitpick and not a blocker from my end.

    I would invite broad feedback on this, and hoping someone can help pick it up. CC: @WordPress/gutenberg-design

  2. keoshi commented on Jul 22, 2026

    @keoshi
    Contributor

    Ditto what Joen said above: this is excellent work, @verofasulo! Love the simplicity of the solution you landed on, especially taking into account the complexity of the problem.

    For the nesting, I really dig "Chevron on the left + header". My first instinct when looking at the first option was wondering if these lists would benefit from a expand/collapse all action, and I was delighted at the elegant solution of having a global chevron in the table header. Simple and effective.

    Purely from a visual standpoint, I do prefer “Chevron only”, but also appreciate the counter inside each row that give an overview without any extra clicks. Visually something's off about it (maybe having a lot of horizontally stacked elements in a row), but the functionality-wise it feels crucial.

    In terms of search results, I'm a big fan of "Flat search - 2 lines". Super clean and feels the clearer way to indicate belonging without being visually complex.

    Two aspects of the UX that feel worth surfacing:

    Interactive areas

    Especially in the "Chevron on the left + header" alternative, there are a lot of actions condensed into a very small horizontal space:

    • Chevron for expanding/collapsing sub-tree.
    • Checkbox for selecting an item.
    • Link to that item's single view.
    • Count to surface total children.
    • Row which could also be interactive?

    And this list is just on the first column. Doesn't take into account other columns where individual items might carry their own interactions or the actions column. The fact that the Categories/Tags/Custom Taxonomy page is now full-width should help alleviate the horizontal constraint a bit, but maybe some of the other cleaner options ("Chevron in the badge" or "Chevron only") are worth testing first.

    Selection

    Noticed that selecting a parent doesn't select its children. Usually, ticking a parent selects the entire subtree. Similarly, unticking any child item, or ticking only some of them, drops the parent out of the fully-checked state into an indeterminate state (checkbox with a line -).

    The desired interaction here might depend on what objects are being presented. For example, certain taxonomies could warrant the entire sub-tree to be selected, while other objects perhaps wouldn't. It would be good to define what this interaction looks like for most cases and apply it universally.

  3. fcoveram commented on Jul 28, 2026

    @fcoveram
    Contributor

    Great great exploration Veronica ✨

    The TL;DR I lean on is:

    • Chevron on the left + header
    • Flat search - 2 lines

    I don't have much to say about the interaction nuances as WordPress components address the use cases I have in mind.

    For the breadcrumb in flat search, we should tap into the breadcrumbs component from @wordpress/admin-ui. Improving the responsiveness there would benefit both elements and makes the maintainance easier.

    Have you considered showing the nestation without the expand/collapse control? The current in wp-admin and site admin already show this.

    Image Image

    Have you considered how manual order and automatic sort can work together? I acknowledge it’s not part of what you’re exploring, but I’m wondering about interaction nuances with nested elements. The rule I’m thinking of is that when manual ordering is permitted, sorting by the column header should be a one-time action.

  4. verofasulo commented on Jul 29, 2026

    @verofasulo
    Author
    • Chevron on the left + header
    • Flat search – 2 lines

    Nice, it looks like we’re aligned on these two approaches!

    Especially in the "Chevron on the left + header" alternative, there are a lot of actions condensed into a very small horizontal space:

    @Filipe, 100%. If we also consider adding reordering functionality, the interaction complexity increases even further. At the same time, these are all common patterns in modern products, and I think users’ expectations of finding these functionalities outweigh the drawbacks of a more crowded interface. Wdyt?

    Noticed that selecting a parent doesn't select its children. Usually, ticking a parent selects the entire subtree. Similarly, unticking any child item, or ticking only some of them, drops the parent out of the fully-checked state into an indeterminate state. The desired interaction here might depend on what objects are being presented. For example, certain taxonomies could warrant the entire sub-tree to be selected, while other objects perhaps wouldn't. It would be good to define what this interaction looks like for most cases and apply it universally.

    That’s such a good point. I’d be curious to hear @ntsekouras and @gigitux ’s thoughts on this.

    For the breadcrumb in flat search, we should tap into the breadcrumbs component from @wordpress/admin-ui.

    @francisco, that’s a nice idea. We’d need a smaller variant, though: the default is 15px, while a small or compact version could be 12px.
    I also wouldn’t expect the items to be links, which is the current behaviour of the breadcrumbs component. I imagine them being static and communicating belonging and hierarchy rather than acting as a navigation component. Does that make sense to you?
    @ntsekouras, I’d also be curious to hear your opinion on how we should approach this at the component level.

    Have you considered showing the nestation without the expand/collapse control? The current in wp-admin and site admin already show this.

    Do you mean offering both a nested parent–child view and an almost-flat view as alternatives? I don’t think the latter works particularly well, and it currently creates several issues, but maybe you've encountered use cases where the fully nested approach might not work as well?

    Have you considered how manual order and automatic sort can work together? I acknowledge it’s not part of what you’re exploring, but I’m wondering about interaction nuances with nested elements. The rule I’m thinking of is that when manual ordering is permitted, sorting by the column header should be a one-time action.

    Oh, that’s such a good point. @fcoveram Could you expand on what you mean by “sorting by the column header should be a one-time action”?
    Would it work something like this: you click “Name” to sort alphabetically, and the rows visually rearrange in that moment, but the system doesn’t treat this as the new persistent ordering rule. The existing manual order is preserved underneath and remains the “real” order. If you refresh the page, add a new item, or navigate away and return, you would see the manual order again rather than the alphabetical one. Is that what you had in mind?

  5. fcoveram commented on Jul 30, 2026

    @fcoveram
    Contributor

    @francisco, that’s a nice idea. We’d need a smaller variant, though: the default is 15px, while a small or compact version could be 12px. I also wouldn’t expect the items to be links, which is the current behaviour of the breadcrumbs component. I imagine them being static and communicating belonging and hierarchy rather than acting as a navigation component. Does that make sense to you?

    Agree with you. For the size, I think it's possible to use the same component (perhaps not in its current state, as it needs to integrate the font-size prop) with --wpds-typography-font-size-sm to show 12px. Regarding the link, I think this could also be part of the breadcrumb component, as there are other cases where the breadcrumb path is only declarative and doesn't need to be interactive.

    Looking forward to seeing what other folks think of expanding breadcrumb component capabilities.

    Do you mean offering both a nested parent–child view and an almost-flat view as alternatives?

    No. I meant reusing the "Chevron on the left" layout but hiding the expand/collapse action while keeping the indentation space to show there is a parent/child relationship. In the example I shared, that is conveyed by the — symbol (one, or two, or more, depending on the level).

    Oh, that’s such a good point. @fcoveram Could you expand on what you mean by “sorting by the column header should be a one-time action”?

    It's similar to your example, but I will elaborate more to make sure we're talking about the same thing. I also found that spreadsheet addresses this very well.

    CleanShot.2026-07-30.at.11.46.04.mp4

    In a list of entries

    • Sorting by any criteria (ie, A → Z) works just once. It's not a persistent value.
    • Moving entry(ies) position is saved in the system.
    • Leaving the screen and coming back shows the latest order of entries. Nothing has changed.
    • Adding/removing an entry does not affect the entries' order.
    • Sorting again works as in the first point.

    Does this make sense to you?

  6. verofasulo commented on Aug 10, 2026

    @verofasulo
    Author

    Does this make sense to you?

    Yes, that makes sense to me and the video attached is such a good example. 🙂 It's Google Sheets, right?


    I was checking Wix for other reasons and noticed they recently implemented subcategories. Sharing because it’s relevant to this stream of work, and it’s interesting to see that they landed on a direction very similar to the one we’re leaning toward.

    They allow users to collapse and expand both at the master level and for individual categories, support reordering (which is something we still need to work on), and use a flat search with breadcrumbs as well.

    Wix.categories.mov
  7. fcoveram commented on Aug 10, 2026

    @fcoveram
    Contributor

    It's Google Sheets, right?

    Yep 🙂

    Wix feels simpler, but I'd say that your proposal for breadcrumb in flat search feels cleaner. It scales better when texts are long.

  8. annezazu commented on Sep 6, 2026

    @annezazu
    Contributor

    @verofasulo when you have time, can you share an update here that clearly shows which option you explored has alignment from design that a dev can work on? Reading this over, it's not quite clear and I'd love to see if we can get dev help on this for 7.2.

  9. self-assigned this
    on Sep 8, 2026
  10. verofasulo commented on Sep 8, 2026

    @verofasulo
    Author

    @annezazu sure thing! Here's where things landed after the discussion above.

    Direction with design alignment

    Nesting.mp4
    • Affordance: "Chevron on the left + header."** A disclosure chevron on the left of each parent row to expand/collapse its children, plus a "master" chevron in the table header that expands/collapses all levels at once. You can see it in the prototype: https://hierarchical-nesting.vercel.app/?variations=inline-header&search=flat-2line
    • Search: "Flat search – 2 lines." Search returns a flat result set where each match shows on the first line and its ancestor path underneath as a non-interactive breadcrumb.
    • Sorting within each level. Top-level items are sorted together and each parent's children are sorted within that parent, so a sort never separates children from their parent.
    • Pagination: per-level "load more" instead of an items-per-page setting, so a very large top level or a parent with many children stays bounded.
    • Scope: table layout only.

    Decisions taken on the open questions

    • Child counts: this needs a feasibility check. Showing the count is important in certain scenarios, so if there aren't severe performance concerns, the badge should be part of the implementation. Either way it should be optional, so it can be disabled for features that don't need it.
    • Breadcrumbs in search: the plan is to reuse the breadcrumbs component from @wordpress/admin-ui, in a smaller (12px / --wpds-typography-font-size-sm) and non-linked variant. That may need a small extension of the component.
    • Selection: per-row, and it does not cascade to children by default. Selecting the subtree should be available as an opt-in, not the baseline. The reasoning: for most entities that would get a tree view, the parent–child relationship is structural, not compositional — a subcategory is an independent item that happens to point at a parent, not something "contained" in it. If I tick a parent and run a bulk action, I almost certainly mean that one item; silently expanding the selection would turn a single-item action into a multi-item one. It also doesn't play well with per-level "load more": cascading would mean selecting rows the user hasn't loaded or seen, or selecting only the loaded ones and pretending that's the subtree. Keeping selection strictly per-row means the selection state is always exactly what's visible and checked. For entities where children are genuinely owned by the parent and an action on the parent implies the same on its children, cascading (with the parent moving to an indeterminate state when only some children are selected) could be enabled per entity.

    Still open (shouldn't block a first implementation)

    @dinhtungdu @gigitux since you're picking this up, I'm available for any questions or to clarify anything that's unclear — feel free to ping me anytime. 🙂

  11. dinhtungdu commented on Oct 12, 2026

    @dinhtungdu
    Member

    In the stack at #83315, I got the UI working as design: expansion, pagination, search are working. But there is a catch: the collectiton response categories or pages or any hierarchical data now doesn't have a property indicate an item has children or not, so:

    • We have to assume an item has a child and only know the definite answer when expanding that item, like my stack is doing.
    • Or we have to make N request with N is the number of current visible items on the page, and do the same of any revealed children.
    Screen.Recording.2026-10-12.at.15.10.34.mov

    To have real hierarchy, we will need to update the REST API collection response of hierarchical items like page or hierarchical taxonomies in Core. I think about has_children vs child_count, but for collection data, we probably should just go with a bool has_children for scalability.

    Do you agree has_children is a blocker or we should try shipping some other parts while working on adding that property? cc @verofasulo @oandregal @ntsekouras @gigitux

  12. gigitux commented on Oct 12, 2026

    @gigitux
    Contributor

    Do you agree has_children is a blocker or we should try shipping some other parts while working on adding that property? cc @verofasulo @oandregal @ntsekouras @gigitux

    I haven’t checked the code yet, but I think it makes sense to split the work.

    DataViews is a generic library, so we can implement the hierarchical view independently, allowing consumers whose REST APIs already expose the necessary information to start using it. On the WordPress side, we’ll also need to update the REST API endpoint to expose that information.

    With that in mind, I’d split the work into three parts:

    1. DataViews: Implement the hierarchical view.
    2. REST API: Add the has_children field to the relevant endpoint.
    3. WordPress integration: Update the Pages screen that consumes DataViews to support hierarchical nesting UI
  13. dinhtungdu commented on Oct 12, 2026

    @dinhtungdu
    Member

    Ah yes, it makes sense. The current stack is already support the first part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Needs DevReady for, and needs developer efforts[Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond[Package] DataViews/packages/dataviews[Type] EnhancementA suggestion for improvement.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions