Skip to content

DataViews: collapse/expand parent row - #83316

Open
dinhtungdu wants to merge 1 commit into
fix/80360from
fix/80360-controlled-expansion
Open

dinhtungdu wants to merge 1 commit into
fix/80360from
fix/80360-controlled-expansion

Conversation

@dinhtungdu

@dinhtungdu dinhtungdu commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

What?

Part of #80360. Stacked on #83315.

Adds expand and collapse to hierarchical DataViews tables. The consumer controls which rows are expanded.

Why?

With #83315, a table shows every loaded item in its place in the tree. A big tree becomes one long list, so users need to hide and show a parent's children.

How?

  • Each parent row gets an expand button, and the header gets Expand all and Collapse all. If the consumer doesn't know yet whether a row has children, the row still gets the button.
  • In tree mode the checkbox column goes away. The expand button, the checkbox and the title share the first cell and indent together by level.
  • Collapsing hides rows but keeps their selection, so Select all also selects loaded rows under a collapsed parent. MUI X, TanStack Table and AG Grid do the same, and the README says so. The bulk actions bar starts at Select all, so Expand all stays usable while rows are selected.

Flat and grouped tables do not change. Loading children in batches comes in #83320.

Testing Instructions

  1. Run npm run test:unit:vitest -- packages/dataviews.
  2. In Storybook, open DataViews → Hierarchical Levels. Sun starts expanded.
  3. Click the arrow next to Sun. Its children hide. Click it again. They come back.
  4. Click Expand all in the header. Every loaded parent expands, and the button changes to Collapse all. Click it. Only the top-level rows remain.
  5. Expand all again and select Earth. Its child Moon stays unselected.
  6. Collapse Sun and click Select all. The bar's checkbox appears exactly where Select all was, and Expand all stays visible. Expand Sun. Its children are selected. Click the same spot again. The selection clears.
  7. Switch Storybook to RTL and repeat step 6.
  8. Turn off the showLevels control. The flat table comes back, with its checkbox column.

Testing Instructions for Keyboard

  1. Tab to a row's expand button and press Enter. Its children hide or show.
  2. Tab to Select all and press Space. Focus moves to Deselect all in the bar. Press Space again. Focus returns to Select all.

Screenshots or screencast

Captured before the rebase onto #86829. On the current head, the checkbox, Expand all and the bulk actions bar sit at the same positions in LTR and RTL, at 375, 782 and 1280 px.

Sun, Earth and Moon with the expand button, checkbox and title indenting together

Use of AI Tools

OpenAI Codex through Pi drafted the first implementation and tests. Amp reviewed and simplified the stack, rebased it on trunk, and checked it in a browser.

@dinhtungdu
dinhtungdu added this pull request to stack #83317 September 22, 2026 04:23
@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Sep 22, 2026
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from c163fbf to 585385b Compare September 22, 2026 04:25
@dinhtungdu dinhtungdu changed the title fix/80360 controlled expansion DataViews: add controlled hierarchy expansion Sep 22, 2026
@dinhtungdu dinhtungdu added the [Type] New API New API to be used by plugin developers or package users. label Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @ampagent.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: ampagent.

Co-authored-by: dinhtungdu <dinhtungdu@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +4.44 kB (+0.05%)

Total Size: 8.71 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 559 kB +789 B (+0.14%)
build/scripts/edit-site/index.min.js 385 kB +1.05 kB (+0.27%)
build/scripts/editor/index.min.js 575 kB +793 B (+0.14%)
build/scripts/media-utils/index.min.js 239 kB +786 B (+0.33%)
build/styles/edit-site/style-rtl.css 21.4 kB +99 B (+0.46%)
build/styles/edit-site/style-rtl.min.css 17.4 kB +155 B (+0.9%)
build/styles/edit-site/style.css 21.4 kB +99 B (+0.46%)
build/styles/edit-site/style.min.css 17.4 kB +156 B (+0.91%)
build/styles/editor/style-rtl.css 32.3 kB +99 B (+0.31%)
build/styles/editor/style-rtl.min.css 28 kB +155 B (+0.56%)
build/styles/editor/style.css 32.4 kB +101 B (+0.31%)
build/styles/editor/style.min.css 28 kB +154 B (+0.55%)

eae54fb Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 8aa8b59 trunk % Change
timeToFirstByte 44.4 ms +7.55% -5.18% 43.9 ms +2.73% -3.76% 1.14%
largestContentfulPaint 72 ms +5.56% -5.56% 68 ms +8.82% -0% 5.88%
lcpMinusTtfb 27 ms +14.07% -12.78% 24.45 ms +23.11% -4.5% 10.43%
wpBeforeTemplate 22.95 ms +10.2% -3.79% 22.5 ms +2.49% -1.38% 2%
wpTemplate 17.56 ms +3.7% -4.84% 17.44 ms +3.56% -4.24% 0.69%
wpTotal 40.94 ms +8.01% -5.5% 40.48 ms +2.79% -3.61% 1.14%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 8aa8b59 trunk % Change
timeToFirstByte 35.3 ms +6.94% -1.13% 36.1 ms +7.76% -3.19% -2.22%
largestContentfulPaint 64 ms +6.25% -0% 64 ms +6.25% -0% 0%
lcpMinusTtfb 29.25 ms +3.59% -1.37% 29.05 ms +1.03% -3.96% 0.69%
wpBeforeTemplate 19.2 ms +3.18% -0.73% 19.56 ms +1.99% -2.56% -1.84%
wpTemplate 13.13 ms +3.35% -3.73% 13.27 ms +1.88% -3.84% -1.06%
wpTotal 32.61 ms +5.12% -1.72% 33.19 ms +5.63% -3.62% -1.75%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 8aa8b59 trunk % Change
mediaProcessingJpeg 327.23 ms +0.96% -0.75% 324.09 ms +0.53% -0.47% 0.97%
mediaProcessingAvif 4934.15 ms +0.3% -0.32% 4891.97 ms +0.48% -0.31% 0.86%
mediaProcessingJpegToAvif 3416.11 ms +0.41% -0.21% 3394.06 ms +0.38% -0.23% 0.65%

media-upload

Metric 8aa8b59 trunk % Change
jpegUploadProcessing 1477.96 ms +1.63% -1.22% 1445.95 ms +1.68% -0.69% 2.21%
pngUploadProcessing 232 ms +13.88% -2.26% 234.55 ms +3.38% -1.65% -1.09%
largeJpegUploadProcessing 1441.2 ms +0.61% -0.67% 1445.19 ms +0.24% -0.65% -0.28%
multipleImageUploadProcessing 1522.82 ms +0.46% -0.41% 1531.63 ms +1.35% -1.4% -0.58%

post-editor

Metric 8aa8b59 trunk % Change
serverResponse 244.04 ms +1.7% -4.17% 231.32 ms +6.75% -3.58% 5.5%
firstPaint 276.49 ms +4.63% -5.34% 240.95 ms +13.53% -3.06% 14.75%
domContentLoaded 490.02 ms +7.88% -0.68% 485.71 ms +1.41% -0.52% 0.89%
loaded 490.77 ms +7.89% -0.65% 486.35 ms +1.45% -0.47% 0.91%
firstContentfulPaint 283.45 ms +14.38% -1.88% 277.76 ms +1.12% -1.52% 2.05%
firstBlock 1302.87 ms +3.44% -0.35% 1298.52 ms +0.37% -1.9% 0.33%
type 11.31 ms +4.16% -9.37% 11.26 ms +3.37% -7.99% 0.44%
typeWithoutInspector 11.57 ms +0.78% -11.32% 10.7 ms +2.71% -6.73% 8.13%
typeWithTopToolbar 14.28 ms +4.55% -4.69% 13.91 ms +4.03% -3.45% 2.66%
typeContainer 5.09 ms +8.25% -4.72% 5.08 ms +2.95% -7.87% 0.2%
focus 61.41 ms +5.75% -5.44% 58.77 ms +1.33% -1.96% 4.49%
firstFocus 167.96 ms +0% -0% 148.31 ms +0% -0% 13.25%
selectAll 207.3 ms +0.83% -0.95% 218.56 ms +0.24% -2.37% -5.15%
undo 17.38 ms +3.74% -7.31% 16.84 ms +5.05% -5.29% 3.21%
listViewOpen 33.74 ms +4.77% -1.66% 32.85 ms +9.25% -3.38% 2.71%
inserterOpen 24.28 ms +6.84% -8.15% 24.09 ms +7.68% -7.18% 0.79%
inserterHover 7.03 ms +5.41% -5.41% 7.13 ms +6.45% -4.63% -1.4%
inserterSearch 5.81 ms +6.2% -5.16% 5.62 ms +3.74% -2.14% 3.38%
loadPatterns 386.58 ms +5.77% -2.17% 393.63 ms +1.12% -3.54% -1.79%
wpTotal 237.71 ms +1.67% -4.3% 224.87 ms +6.92% -3.69% 5.71%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.33%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 8aa8b59 trunk % Change
serverResponse 505.53 ms +1.05% -7.51% 472.08 ms +5.27% -3.07% 7.09%
firstPaint 473.58 ms +10.97% -8.89% 436.73 ms +6.05% -3.88% 8.44%
domContentLoaded 934.34 ms +0.85% -3.6% 917.13 ms +1.18% -0.64% 1.88%
loaded 935.44 ms +0.88% -3.59% 918.15 ms +1.18% -0.61% 1.88%
firstContentfulPaint 528.53 ms +1% -3.53% 518.19 ms +2.74% -2.92% 2%
firstBlock 2866.04 ms +6.56% -1.79% 2913.97 ms +0.93% -1.42% -1.64%
type 21.65 ms +5.03% -9.52% 22.21 ms +6.8% -12.79% -2.52%
navigate 137.18 ms +3.93% -3.16% 121.25 ms +4.84% -7.79% 13.14%
loadPatterns 1633.3 ms +3.24% -5.82% 1566.47 ms +1.95% -5.79% 4.27%
loadPages 1048.1 ms +12.17% -0.62% 1014.11 ms +1.87% -1.62% 3.35%
wpTotal 495.85 ms +1.05% -7.7% 460.81 ms +5.73% -2.83% 7.6%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

eae54fb Run

🏁 Flaky tests

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

should select synced pattern in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]') with timeout 5000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
    14 × locator resolved to <div tabindex="0" role="document" draggable="true" data-title="Pattern" data-type="core/block" data-is-drop-zone="true" aria-label="Block: Pattern" id="block-078640f5-ea66-42e1-b741-666ae9283260" data-block="078640f5-ea66-42e1-b741-666ae9283260" class="block-editor-block-list__block wp-block is-selected is-reusable block-library-block__reusable-block-container wp-block-block block-editor-block-list__layout">…</div>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:1464:5

eae54fb Run

@dinhtungdu
dinhtungdu removed this pull request from stack #83317 October 6, 2026 12:26
@dinhtungdu
dinhtungdu added this pull request to stack #84117 October 6, 2026 12:27
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from 094e860 to 8048085 Compare October 12, 2026 03:42
@dinhtungdu
dinhtungdu removed this pull request from stack #84117 October 12, 2026 14:21
@dinhtungdu
dinhtungdu added this pull request to stack #84566 October 12, 2026 14:21
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from 8048085 to a634737 Compare October 15, 2026 08:12
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from a634737 to 4e7f72b Compare November 19, 2026 05:56
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from 4e7f72b to 831d4fb Compare November 19, 2026 09:32
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from 831d4fb to f793908 Compare November 19, 2026 15:06
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from f793908 to cc8391c Compare November 19, 2026 16:58
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from cc8391c to e4d51f7 Compare November 23, 2026 07:03
@dinhtungdu dinhtungdu changed the title DataViews: add controlled hierarchy expansion DataViews: collapse/expand parent row Nov 23, 2026
@dinhtungdu
dinhtungdu marked this pull request as ready for review November 23, 2026 08:31
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from e4d51f7 to 466d447 Compare November 23, 2026 10:30
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from 466d447 to c280cc0 Compare November 23, 2026 13:19
@dinhtungdu
dinhtungdu marked this pull request as draft November 23, 2026 14:04
@dinhtungdu
dinhtungdu force-pushed the fix/80360-controlled-expansion branch from c280cc0 to eae54fb Compare November 24, 2026 03:57
@dinhtungdu
dinhtungdu marked this pull request as ready for review November 24, 2026 04:21

This branch has not been deployed

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

Labels

[Package] DataViews /packages/dataviews [Type] New API New API to be used by plugin developers or package users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant