Skip to content

Gallery: Move the Settings panel into its own component - #86768

Merged
Mamaduka merged 1 commit into
trunkfrom
update/gallery-settings-panel
Nov 13, 2026
Merged

Mamaduka merged 1 commit into
trunkfrom
update/gallery-settings-panel

Conversation

@Mamaduka

Copy link
Copy Markdown
Member

What?

Follow up to #86767.

Moves the Settings ToolsPanel from edit.jsx into GalleryControls in controls.jsx, and replaces the useImageSizes hook with a plain getImageSizeOptions. No user-visible change.

Why?

Review on #86648 asked to move testable pieces out of edit.jsx, which drops from 1,164 to 579 lines. GalleryControls renders inside InspectorControls, which renders nothing for an unselected block, so the panel's work only runs for the selected gallery and image sizes no longer need an isSelected gate.

How?

appliedSort stays in edit, because the panel unmounts on deselect and Order by would reset to Custom. The InspectorControls group now depends on the viewport state alone, and the panel returns null when a viewport state has no settings to show, since the aspect ratio options that check needs moved into the panel. The file stays .jsx: a .tsx panel would import eight gallery JS modules, which fails type check with TS6307.

Testing Instructions

  1. Open a post or page.
  2. Insert a Gallery block and add three large images from the Media Library. Resolution lists only the sizes the images have.
  3. Set Order by to Oldest to newest, select another block, then reselect the gallery. Order by still shows Oldest to newest.
  4. Open View, choose Mobile, and turn on Responsive styles. Settings shows only Columns, Aspect ratio, and Crop images to fit, and changing them only affects the Mobile view.
  5. Switch View back to Desktop, change several settings, then open Settings options and choose Reset all. Every setting returns to its default.

Testing Instructions for Keyboard

Same as above.

Use of AI Tools

Assisted by Claude.

@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality [Package] Block library /packages/block-library [Block] Gallery Affects the Gallery Block - used to display groups of images labels Nov 12, 2026
@Mamaduka Mamaduka self-assigned this Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 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: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@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: -73 B (0%)

Total Size: 8.64 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 427 kB -73 B (-0.02%)

28a9795 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 31d8d39 trunk % Change
timeToFirstByte 49.6 ms +5.95% -8.47% 48.55 ms +5.97% -2.47% 2.16%
largestContentfulPaint 76 ms +15.79% -5.26% 80 ms +5% -5% -5%
lcpMinusTtfb 25.95 ms +29.67% -3.47% 29.8 ms +12.75% -10.74% -12.92%
wpBeforeTemplate 25.35 ms +12.39% -5.4% 25.18 ms +9.77% -0.95% 0.68%
wpTemplate 18.8 ms +9.89% -7.55% 19.1 ms +7.59% -5.76% -1.57%
wpTotal 45.76 ms +6.23% -8.78% 44.89 ms +5.44% -3.01% 1.94%
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 31d8d39 trunk % Change
timeToFirstByte 38.65 ms +5.56% -4.27% 39.7 ms +8.44% -1.89% -2.64%
largestContentfulPaint 68 ms +5.88% -0% 72 ms +5.56% -0% -5.56%
lcpMinusTtfb 31.15 ms +1.77% -4.98% 32.2 ms +2.02% -5.28% -3.26%
wpBeforeTemplate 20.93 ms +10.08% -1.67% 21.66 ms +2.12% -1.39% -3.37%
wpTemplate 13.65 ms +5.2% -1.76% 14.58 ms +4.25% -3.36% -6.38%
wpTotal 35.22 ms +6.39% -3.15% 36.33 ms +6.11% -1.32% -3.06%
wpMemoryUsage 6.44 MB +0% -0% 6.40 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 31d8d39 trunk % Change
mediaProcessingJpeg 345.61 ms +2.37% -1.26% 357.56 ms +0.49% -2.62% -3.34%
mediaProcessingAvif 5110.42 ms +0.86% -0.31% 5239.36 ms +0.5% -0.29% -2.46%
mediaProcessingJpegToAvif 3556.65 ms +0.31% -1.13% 3622.22 ms +0.17% -0.92% -1.81%

media-upload

Metric 31d8d39 trunk % Change
jpegUploadProcessing 1487.51 ms +2.17% -1.53% 1491.65 ms +1.68% -0.74% -0.28%
pngUploadProcessing 248.83 ms +3.85% -2.02% 259.21 ms +5.5% -4.85% -4%
largeJpegUploadProcessing 1450.15 ms +0.64% -0.39% 1473.88 ms +0.63% -0.87% -1.61%
multipleImageUploadProcessing 1599.78 ms +0.55% -2.32% 1596.81 ms +2.34% -2.73% 0.19%

post-editor

Metric 31d8d39 trunk % Change
serverResponse 396.71 ms +2.35% -8.54% 400.11 ms +1.51% -2.02% -0.85%
firstPaint 406.49 ms +7.13% -7.21% 400.56 ms +6.24% -7.21% 1.48%
domContentLoaded 764.2 ms +14.21% -2.01% 750.97 ms +1.57% -1.1% 1.76%
loaded 765.22 ms +14.19% -2% 751.85 ms +1.56% -1.08% 1.78%
firstContentfulPaint 435.08 ms +19.52% -2.74% 427.54 ms +1.57% -0.7% 1.76%
firstBlock 1976.39 ms +1.17% -2.88% 1923.18 ms +1.28% -1.94% 2.77%
type 16.78 ms +3.75% -11.56% 16.91 ms +3.61% -9.7% -0.77%
typeWithoutInspector 17.03 ms +2% -15.03% 17.04 ms +4.93% -15.32% -0.06%
typeWithTopToolbar 21.65 ms +7.21% -8.13% 21.36 ms +4.78% -2.86% 1.36%
typeContainer 8.27 ms +3.51% -9.79% 8.35 ms +3.35% -7.43% -0.96%
focus 109.45 ms +8.9% -1.34% 102.97 ms +7% -1.16% 6.29%
firstFocus 240.39 ms +0% -0% 229.25 ms +0% -0% 4.86%
selectAll 317.74 ms +0.49% -2.31% 314.16 ms +1.69% -1.66% 1.14%
undo 27.54 ms +1.53% -5.16% 26.3 ms +8.48% -4.41% 4.71%
listViewOpen 71.35 ms +9.92% -13.24% 67.75 ms +7.45% -7.48% 5.31%
inserterOpen 39.62 ms +2.9% -5.63% 39.66 ms +9.4% -6.35% -0.1%
inserterHover 11.4 ms +6.49% -12.11% 10.48 ms +17.18% -4.58% 8.78%
inserterSearch 7.76 ms +9.79% -6.19% 8.45 ms +5.44% -4.26% -8.17%
loadPatterns 607.15 ms +6.99% -2.93% 600.18 ms +3.76% -2.04% 1.16%
wpTotal 387.09 ms +2.32% -8.7% 390.11 ms +1.42% -1.94% -0.77%
wpMemoryUsage 14.81 MB +0% -0% 14.77 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 31d8d39 trunk % Change
serverResponse 416.12 ms +1.4% -10.25% 416.97 ms +1.54% -7.94% -0.2%
firstPaint 482.73 ms +6.62% -3.49% 426.54 ms +2.72% -6% 13.17%
domContentLoaded 863.57 ms +5.21% -2.96% 868.78 ms +1.73% -0.9% -0.6%
loaded 864.61 ms +5.2% -2.95% 869.98 ms +1.74% -0.89% -0.62%
firstContentfulPaint 492.82 ms +7.44% -3.5% 481.77 ms +4.53% -1.22% 2.29%
firstBlock 2592.11 ms +5.29% -1.65% 2601.6 ms +0.52% -2.41% -0.36%
type 19.98 ms +2.05% -8.21% 20.15 ms +6.35% -9.43% -0.84%
navigate 122.08 ms +4.76% -2.93% 118.58 ms +5.14% -5.24% 2.95%
loadPatterns 1308.28 ms +5.64% -7.51% 1531.96 ms +5.53% -18.29% -14.6%
loadPages 927.76 ms +2.57% -1.5% 930.83 ms +2.26% -1.27% -0.33%
wpTotal 405.04 ms +1.47% -10.43% 406.08 ms +1.62% -8.15% -0.26%
wpMemoryUsage 12.82 MB +0% -0% 12.79 MB +0% -0% 0.25%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

28a9795 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.

Navigates the list via UP/DOWN arrow keys from action buttons in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-173-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:243:5
page-list submenu user interactions in /test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Save', exact: true })
    - locator resolved to <button type="button" aria-disabled="true" class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact">Save</button>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
      - waiting 100ms
    16 × waiting for element to be visible, enabled and stable
       - element is not enabled
     - retrying click action
       - waiting 500ms

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:39:22)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:598:4
should reset a named font size using input field in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"small"} -->
+ <!-- wp:paragraph {"fontSize":"tiny"} -->
- <p class="has-small-font-size">Paragraph with font size reset using input field</p>
+ <p class="has-tiny-font-size">Paragraph with font size reset using input field</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:216:6

28a9795 Run

Base automatically changed from update/gallery-inner-image-handlers to trunk November 13, 2026 05:47
Panel renders inside InspectorControls, so its work runs only while the block is selected. Replace useImageSizes with a plain getImageSizeOptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mamaduka
Mamaduka force-pushed the update/gallery-settings-panel branch from c737c21 to 28a9795 Compare November 13, 2026 05:48

@andrewserong andrewserong left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, it's such a breath of fresh air to see the controls moved out to their own file, thanks for this 🙂

All settings are smoke-testing well for me in the regular gallery, the dynamic gallery, and in responsive styles editing mode.

And reading the code change, the logic all appears to line up appropriately across the removals + additions.

LGTM! 🚀

@Mamaduka

Copy link
Copy Markdown
Member Author

Thanks for testing and reviews, @andrewserong!

@Mamaduka
Mamaduka merged commit a4efa87 into trunk Nov 13, 2026
85 checks passed
@Mamaduka
Mamaduka deleted the update/gallery-settings-panel branch November 13, 2026 06:12
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 13, 2026
Comment on lines +1832 to +1837
"gutenberg/use-typescript": {
"count": 1
},
"react/jsx-filename-extension": {
"count": 1
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recognizing that a lot of the file was moved from an existing .jsx, could we have adapted this to TypeScript in creating the new file?

Separate observation on linting in general: It's probably redundant that we have both rules covering the use of TypeScript in files with JSX syntax.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to keep this a pure extraction PR; things are harder to review when you stack different refactorings.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'd treat converting the Gallery block to TS as a separate task to this kind of refactor. It's a very prominently used block and can be quite tricky to make changes to without breaking anything.

But yes, let's eventually get it in TS!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair 👍 I think in the general case I'd argue that we probably shouldn't refactor for its own sake and that these kinds of moves are good opportunities to clean up existing issues. But given the size and relative risk here I think it's fair for that to be its own separate effort.

Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
Panel renders inside InspectorControls, so its work runs only while the block is selected. Replace useImageSizes with a plain getImageSizeOptions.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Gallery Affects the Gallery Block - used to display groups of images [Package] Block library /packages/block-library [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants