Skip to content

QueryControls: Migrate ordering to UI SelectControl - #87078

Open
ciampo wants to merge 6 commits into
trunkfrom
codex/query-controls-selectcontrol
Open

ciampo wants to merge 6 commits into
trunkfrom
codex/query-controls-selectcontrol

Conversation

@ciampo

@ciampo ciampo commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

See #80412.

What?

Migrate the Order by field in QueryControls, used by the Latest Posts block, to SelectControl from @wordpress/ui.

Why?

This gives Latest Posts the same dropdown as the other migrated block settings. The field shows the Select placeholder when the current sort is missing or unavailable. See the discussion about missing options.

How?

Match the current sort against the supplied options. Hide the field when the options list is empty and call each sort callback only when its value changes.

Testing Instructions

  1. Publish posts with different titles and dates. Insert a Latest Posts block and open Sorting and filtering in the block settings.
  2. Try all four Order by options. Check that the preview updates and that the field shows the selected order. Save and reopen the post to verify the selection persists.
  3. In the QueryControls Default Storybook story, set orderByOptions to [{"label":"Menu order","value":"menu_order/asc"}]. The field shows Select until you choose Menu order. Set orderByOptions to [] and check that the field disappears.

Testing Instructions for Keyboard

  1. Tab to Order by and press Enter. Use the arrow keys to highlight a different option and press Enter to select it.
  2. Check that the preview updates and focus returns to Order by. Open it again, move to a different option, and press Escape. Check that focus returns and the selected sort stays the same.

Screenshots

The Latest Posts block's Sorting and filtering settings in Chrome on macOS.

State Before After
Closed Native Order by select closed WordPress UI Order by select closed
Open Native Order by menu showing all four options WordPress UI Order by menu showing all four options

Use of AI Tools

Codex drafted the implementation, browser tests, and PR description.

@github-actions github-actions Bot added the [Package] Components /packages/components label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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

Co-authored-by: ciampo <mciampini@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: +91 B (0%)

Total Size: 8.68 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 427 kB +19 B (0%)
build/scripts/components/index.min.js 345 kB +72 B (+0.02%)

6b789ea Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 6a13c39 trunk % Change
timeToFirstByte 50.25 ms +3.38% -3.18% 51.2 ms +6.84% -4.79% -1.86%
largestContentfulPaint 84 ms +4.76% -4.76% 82 ms +12.2% -4.88% 2.44%
lcpMinusTtfb 30.9 ms +22.01% -8.58% 29.3 ms +19.28% -6.66% 5.46%
wpBeforeTemplate 25.51 ms +3.76% -3.76% 24.98 ms +10.33% -2% 2.12%
wpTemplate 20.62 ms +4.9% -3.3% 21.24 ms +5.79% -3.39% -2.92%
wpTotal 46.3 ms +3.11% -3.46% 47.18 ms +6.91% -4.94% -1.87%
wpMemoryUsage 7.75 MB +0% -0% 7.71 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 6a13c39 trunk % Change
timeToFirstByte 41.3 ms +3.75% -3.63% 41.9 ms +2.86% -2.98% -1.43%
largestContentfulPaint 76 ms +0% -5.26% 76 ms +2.63% -0% 0%
lcpMinusTtfb 33.7 ms +4.45% -2.67% 34.85 ms +3.01% -4.73% -3.3%
wpBeforeTemplate 21.89 ms +5.3% -1.6% 21.89 ms +6.17% -2.38% 0%
wpTemplate 15.75 ms +4.06% -4.06% 16.27 ms +6.95% -4.98% -3.2%
wpTotal 37.86 ms +4.62% -3.35% 38.56 ms +2.77% -2.52% -1.82%
wpMemoryUsage 6.44 MB +0% -0% 6.40 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 6a13c39 trunk % Change
mediaProcessingJpeg 404.44 ms +1.57% -1.07% 403.84 ms +0.26% -1.19% 0.15%
mediaProcessingAvif 5913.79 ms +0.56% -0.6% 5873.13 ms +0.38% -0.16% 0.69%
mediaProcessingJpegToAvif 4007.2 ms +0.41% -0.32% 4021.49 ms +0.13% -0.27% -0.36%

media-upload

Metric 6a13c39 trunk % Change
jpegUploadProcessing 1760.38 ms +14.92% -14.28% 1496.48 ms +0.9% -0.29% 17.63%
pngUploadProcessing 259.62 ms +2.43% -3.17% 259.13 ms +6.56% -3.37% 0.19%
largeJpegUploadProcessing 1500.89 ms +0.25% -0.49% 1505.41 ms +31.05% -0.89% -0.3%
multipleImageUploadProcessing 2077.37 ms +1.56% -5.71% 2149.96 ms +0.3% -2.56% -3.38%

post-editor

Metric 6a13c39 trunk % Change
serverResponse 328.53 ms +4.52% -9.06% 307.17 ms +6.35% -4.77% 6.95%
firstPaint 331.97 ms +4.09% -2.81% 317.41 ms +12.47% -4.36% 4.59%
domContentLoaded 650.77 ms +0.9% -0.59% 635.67 ms +1.3% -1.09% 2.38%
loaded 651.57 ms +0.91% -0.58% 636.41 ms +1.32% -1.08% 2.38%
firstContentfulPaint 373.46 ms +1.69% -2.29% 357.34 ms +3.15% -0.28% 4.51%
firstBlock 1735.5 ms +0.77% -2.17% 1694.82 ms +2.27% -1.87% 2.4%
type 14.93 ms +5.29% -9.24% 14.76 ms +4% -8.81% 1.15%
typeWithoutInspector 14.48 ms +4.35% -2.62% 15.89 ms +4.72% -5.35% -8.87%
typeWithTopToolbar 19.1 ms +14.61% -6.81% 21.16 ms +5.48% -3.21% -9.74%
typeContainer 6.84 ms +10.09% -7.89% 6.96 ms +11.78% -7.76% -1.72%
focus 107.05 ms +6.03% -7.12% 96.26 ms +4.9% -3.33% 11.21%
firstFocus 214.9 ms +0% -0% 209.4 ms +0% -0% 2.63%
selectAll 326.09 ms +3.02% -3.97% 303.14 ms +5.75% -0.4% 7.57%
undo 25.43 ms +5.66% -1.97% 24.2 ms +4.01% -5.74% 5.08%
listViewOpen 64.97 ms +16.61% -3.54% 56.33 ms +20.54% -8.18% 15.34%
inserterOpen 33.08 ms +9.43% -5.71% 32.52 ms +5.97% -8.15% 1.72%
inserterHover 10.23 ms +7.62% -6.94% 9.27 ms +7.66% -5.93% 10.36%
inserterSearch 6.98 ms +10.6% -5.59% 6.71 ms +4.62% -1.04% 4.02%
loadPatterns 514.84 ms +6.13% -5.42% 510.76 ms +6.76% -1.91% 0.8%
wpTotal 318.97 ms +4.85% -9.01% 298.68 ms +6.46% -4.97% 6.79%
wpMemoryUsage 14.81 MB +0% -0% 14.77 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 6a13c39 trunk % Change
serverResponse 317.17 ms +1.31% -9.55% 296.51 ms +7.28% -4.82% 6.97%
firstPaint 361.8 ms +6.99% -11.2% 323.89 ms +13.67% -2.84% 11.7%
domContentLoaded 673.15 ms +0.78% -1.74% 655.86 ms +0.88% -0.74% 2.64%
loaded 674.07 ms +0.79% -1.75% 656.61 ms +0.89% -0.71% 2.66%
firstContentfulPaint 381.12 ms +1.79% -2.53% 375.83 ms +3.65% -2.91% 1.41%
firstBlock 2041.56 ms +0.26% -0.4% 1983.79 ms +2.15% -0.73% 2.91%
type 15.79 ms +11.72% -10.13% 15.83 ms +4.42% -12.13% -0.25%
navigate 92.96 ms +3.89% -1.09% 88.51 ms +2.37% -3.08% 5.03%
loadPatterns 1168.26 ms +9.73% -2.83% 948.02 ms +11.12% -11.53% 23.23%
loadPages 976.86 ms +2.28% -6.21% 1000.22 ms +0.94% -3.54% -2.34%
wpTotal 308.86 ms +1.32% -9.83% 288.19 ms +7.42% -4.97% 7.17%
wpMemoryUsage 12.82 MB +0% -0% 12.79 MB +0% -0% 0.25%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

6b789ea 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.

a navigation superseded by the traversal discharges to idle in /test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts, passed after 1 failed attempt.
SyntaxError: Unexpected token 'o', "not hydrated" is not valid JSON
    at readLog (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:28:14)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:47:24
    at waitForLogLength (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:46:2)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:693:5
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
does not select blocks in the canvas preview when editing from the sidebar in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByRole('listbox', { name: 'Search results' })
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" getByRole('listbox', { name: 'Search results' }) with timeout 5000ms
  - waiting for getByRole('listbox', { name: 'Search results' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:423:33)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:3
should restore an older revision in /test/e2e/specs/editor/various/revisions.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
      "attributes": Object {
-       "content": "Original content - Updated content - Autosaved",
+       "content": "Original content",
      },
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/revisions.spec.js:146:5
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-400d5892-8974-44af-881a-093461bb97e3" data-block="400d5892-8974-44af-881a-093461bb97e3" 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

6b789ea Run

@ciampo ciampo self-assigned this Nov 19, 2026
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Nov 19, 2026
@ciampo
ciampo marked this pull request as ready for review November 19, 2026 15:20
@ciampo
ciampo requested a review from a team as a code owner November 19, 2026 15:20
@github-actions
github-actions Bot requested a review from aduth November 19, 2026 15:20

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] Components /packages/components [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant