Skip to content

DataViews: Add parent relationship support - #83315

Open
dinhtungdu wants to merge 1 commit into
trunkfrom
fix/80360
Open

dinhtungdu wants to merge 1 commit into
trunkfrom
fix/80360

Conversation

@dinhtungdu

@dinhtungdu dinhtungdu commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

What?

Part of #80360.

Adds a getItemParentId callback to DataViews. With view.showLevels on, the table puts each loaded item under its parent and indents it by its depth.

Why?

getItemLevel can indent a row, but it cannot say which row is its parent. So when a child comes before its parent in data, the table shows it in the wrong place. A parent link fixes that. #83316 and #83320 then build expand, collapse and per-level loading on it.

How?

  • The table starts at each top-level item and walks down to its children, keeping siblings in the order they came in.
  • Without getItemParentId, and in grouped views, the table uses getItemLevel as before.

Testing Instructions

  1. Run npm run test:unit:vitest -- packages/dataviews.
  2. In Storybook, open DataViews → Hierarchical Levels. Earth sits under Sun, one level in, and Moon sits under Earth, two levels in.
  3. Turn off the showLevels control. The rows go back to plain order by title, with no indent.

Testing Instructions for Keyboard

No keyboard behavior changes.

Screenshots or screencast

Not applicable. This PR changes the row order and reuses the existing indent.

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.

@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Sep 22, 2026
@dinhtungdu
dinhtungdu added this pull request to stack #83317 September 22, 2026 04:23
@dinhtungdu dinhtungdu added the [Type] New API New API to be used by plugin developers or package users. label Sep 22, 2026
@dinhtungdu dinhtungdu changed the title fix/80360 DataViews: Add parent relationship support 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: +917 B (+0.01%)

Total Size: 8.71 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 558 kB +241 B (+0.04%)
build/scripts/edit-site/index.min.js 383 kB +309 B (+0.08%)
build/scripts/editor/index.min.js 574 kB +137 B (+0.02%)
build/scripts/media-utils/index.min.js 238 kB +230 B (+0.1%)

264d98e Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 295788b trunk % Change
timeToFirstByte 56.8 ms +2.02% -5.19% 55.75 ms +6.64% -2.6% 1.88%
largestContentfulPaint 90 ms +4.44% -6.67% 86 ms +11.63% -2.33% 4.65%
lcpMinusTtfb 34.2 ms +11.99% -16.81% 29.15 ms +28.99% -5.83% 17.32%
wpBeforeTemplate 29.37 ms +6.47% -1.8% 29.6 ms +4.56% -3.18% -0.78%
wpTemplate 22.34 ms +4.52% -3.8% 22.11 ms +5.92% -1.67% 1.04%
wpTotal 52.83 ms +2.2% -4.68% 52.11 ms +6.87% -2.69% 1.38%
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 295788b trunk % Change
timeToFirstByte 47 ms +9.15% -2.02% 47.7 ms +7.76% -3.67% -1.47%
largestContentfulPaint 84 ms +4.76% -4.76% 84 ms +2.38% -4.76% 0%
lcpMinusTtfb 34.85 ms +6.31% -2.3% 33.9 ms +3.54% -2.65% 2.8%
wpBeforeTemplate 26.86 ms +9.49% -1.3% 27.15 ms +10.61% -2.21% -1.07%
wpTemplate 16.63 ms +4.21% -3.67% 16.99 ms +4% -5.06% -2.12%
wpTotal 43.76 ms +9.19% -2.26% 44.58 ms +7.45% -3.7% -1.84%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 295788b trunk % Change
mediaProcessingJpeg 404.07 ms +0.79% -0.88% 402.62 ms +0.72% -0.31% 0.36%
mediaProcessingAvif 6178.45 ms +0.11% -0.44% 6120.86 ms +0.41% -0.29% 0.94%
mediaProcessingJpegToAvif 4240.55 ms +0.49% -0.05% 4235.53 ms +0.07% -0.06% 0.12%

media-upload

Metric 295788b trunk % Change
jpegUploadProcessing 2012.53 ms +1.59% -1.69% 1739.21 ms +14.1% -13.11% 15.72%
pngUploadProcessing 275.79 ms +2.58% -3.75% 279.51 ms +6.4% -3.03% -1.33%
largeJpegUploadProcessing 1963.6 ms +1.31% -22.21% 1965.86 ms +0.58% -21.83% -0.11%
multipleImageUploadProcessing 2125.46 ms +0.76% -1.81% 2056.34 ms +2.82% -0.12% 3.36%

post-editor

Metric 295788b trunk % Change
serverResponse 495.16 ms +0.97% -9.19% 469.55 ms +6.32% -6.11% 5.45%
firstPaint 408.4 ms +12.1% -3.52% 411.4 ms +2.56% -3.91% -0.73%
domContentLoaded 867.21 ms +2.35% -1.34% 834.73 ms +0.92% -2.11% 3.89%
loaded 868.4 ms +2.35% -1.34% 835.94 ms +0.91% -2.11% 3.88%
firstContentfulPaint 485.44 ms +4.4% -1.69% 462.32 ms +1.46% -1.23% 5%
firstBlock 2361.68 ms +4.43% -2.19% 2247.71 ms +1.32% -0.79% 5.07%
type 18.99 ms +5.53% -5.58% 20.22 ms +3.61% -8.01% -6.08%
typeWithoutInspector 19.65 ms +9.01% -17.71% 19.71 ms +2.59% -9.99% -0.3%
typeWithTopToolbar 24.3 ms +6.54% -3.37% 25.27 ms +3.13% -8.47% -3.84%
typeContainer 8.74 ms +2.97% -9.5% 9.31 ms +18.37% -13.96% -6.12%
focus 119.14 ms +5.53% -3.57% 110.55 ms +10.56% -6.9% 7.77%
firstFocus 293.59 ms +0% -0% 263.31 ms +0% -0% 11.5%
selectAll 408.63 ms +9.2% -4.53% 410.64 ms +3.55% -0.07% -0.49%
undo 30.4 ms +8.98% -4.74% 31.98 ms +2.88% -10.48% -4.94%
listViewOpen 69.02 ms +1.84% -10.42% 59.42 ms +14.98% -3.87% 16.16%
inserterOpen 42.67 ms +14.44% -10.22% 43.12 ms +13.22% -14.22% -1.04%
inserterHover 12.04 ms +9.55% -5.98% 11.6 ms +7.67% -8.71% 3.79%
inserterSearch 8.41 ms +10.46% -1.43% 8.23 ms +9.11% -4.98% 2.19%
loadPatterns 657.51 ms +4.33% -3.49% 653.27 ms +2.65% -1.06% 0.65%
wpTotal 485.29 ms +0.7% -9.36% 459.84 ms +6.16% -6.21% 5.53%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.33%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 295788b trunk % Change
serverResponse 272.5 ms +3.03% -9.66% 274.04 ms +2.39% -7% -0.56%
firstPaint 333.62 ms +0.35% -15.85% 290.22 ms +12.29% -4% 14.95%
domContentLoaded 593.39 ms +8.98% -2.48% 585.79 ms +4% -0.36% 1.3%
loaded 594.25 ms +8.98% -2.47% 586.64 ms +3.99% -0.35% 1.3%
firstContentfulPaint 333.9 ms +11.7% -1.36% 326.48 ms +6.73% -0.47% 2.27%
firstBlock 1843.41 ms +4.18% -4.48% 1818.52 ms +1.79% -0.83% 1.37%
type 13.97 ms +7.8% -4.58% 14.73 ms +9.71% -5.02% -5.16%
navigate 88.63 ms +11.55% -8.53% 88.56 ms +12.78% -3.07% 0.08%
loadPatterns 1101.6 ms +15.11% -8.5% 1126.2 ms +5.09% -12.36% -2.18%
loadPages 968.17 ms +2.71% -1.3% 946.79 ms +0.99% -0.62% 2.26%
wpTotal 265.58 ms +3.22% -9.84% 267.39 ms +2.42% -7.16% -0.68%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

264d98e 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-9330b620-1140-4ca5-879c-9207fb867f28" data-block="9330b620-1140-4ca5-879c-9207fb867f28" 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

264d98e Run

@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