Repository navigation
Gallery: Move the Settings panel into its own component - #86768
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: -73 B (0%) Total Size: 8.64 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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
|
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>
c737c21 to
28a9795
Compare
There was a problem hiding this comment.
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! 🚀
|
Thanks for testing and reviews, @andrewserong! |
| "gutenberg/use-typescript": { | ||
| "count": 1 | ||
| }, | ||
| "react/jsx-filename-extension": { | ||
| "count": 1 | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Wanted to keep this a pure extraction PR; things are harder to review when you stack different refactorings.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
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>
What?
Follow up to #86767.
Moves the Settings
ToolsPanelfromedit.jsxintoGalleryControlsincontrols.jsx, and replaces theuseImageSizeshook with a plaingetImageSizeOptions. 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.GalleryControlsrenders insideInspectorControls, which renders nothing for an unselected block, so the panel's work only runs for the selected gallery and image sizes no longer need anisSelectedgate.How?
appliedSortstays in edit, because the panel unmounts on deselect and Order by would reset to Custom. TheInspectorControlsgroup 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.tsxpanel would import eight gallery JS modules, which fails type check with TS6307.Testing Instructions
Testing Instructions for Keyboard
Same as above.
Use of AI Tools
Assisted by Claude.