Edit Post: Refactor and cleanup InitPatternModal component#79190
Conversation
|
Size Change: +298 B (0%) Total Size: 8.58 MB 📦 View Changed
|
| "packages/editor/src/components/revision-created-panel/index.js": { | ||
| "@wordpress/use-recommended-components": { | ||
| "count": 1 | ||
| } | ||
| }, |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
5f534f6 to
6884531
Compare
|
Flaky tests detected in 5353e8e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27594720006
|
|
|
||
| // Should be above the popover (dropdown) | ||
| ".reusable-blocks-menu-items__convert-modal": 1000001, | ||
| ".patterns-menu-items__convert-modal": 1000001, |
There was a problem hiding this comment.
We may want to keep the z-index value in this file for the time being.
The reason is that this value is not just a "local" z-index, but it relates to the WordPress/Gutenberg app stacking order
There was a problem hiding this comment.
Interesting, do any old PRs include comparisons, and when is it a good idea to inline? I can revert this change and reuse the same value for both modals.
There was a problem hiding this comment.
There was a problem hiding this comment.
Interesting, do any old PRs include comparisons, and when is it a good idea to inline?
A heuristic is whether the value is small, especially single-digit. That usually signals that the value is only meaningful in a local stacking context, and has no reason to be coordinated in a global file. If feasible, we inline the local z-index, and ideally add an isolation: isolate to create or mark the local stacking context so the internal z-index values don't affect anything else outside of it.
The ultimate goal is to remove the need for globally coordinated values as well, but for now we still need them.
Of course, if a z-index value doesn't seem to be needed anymore, it may be outdated and can be removed though!
| } ); | ||
| } } | ||
| > | ||
| <Stack direction="column" gap="lg"> |
There was a problem hiding this comment.
The previous Stack used a 20px gap (5 * 4px), while the new one currently specifies a 16px.
The new Stack component, in fact, does not offer a 20px option: --wpds-dimension-gap-lg currently maps to 16px, and --wpds-dimension-gap-xl to 24px.
The lack of a 20px option is deliberate (see convo), and therefore I believe that switching to 16px is the correct option. But cc @jasmussen and @fcoveram in case they believe 24px works better, here.
There was a problem hiding this comment.
The lg seems to be a common gap for similar small forms. We should also ensure that CreatePatternModalContents uses the same gap when it's refactored.
| const [ isModalOpen, setIsModalOpen ] = useState( () => isNewPost ); | ||
|
|
||
| if ( ! isNewPost ) { | ||
| if ( ! isModalOpen ) { |
There was a problem hiding this comment.
The new logic here makes sense because the post, in theory, can't transition to non-clean while the modal is open 👍
Maybe worth a comment to why this simple check is fine ?
There was a problem hiding this comment.
IMO, it should be clear why a simple check is fine, a common modal pattern and reading store values in a similar manner isn't new.
I don't count this as a clever hack, otherwise we will have to annotate the whole codebase 😅
|
@jasmussen, the remaining question was whether we should go with a |
|
Yes, the gap on trunk is |
|
Nevermind, I got confused. We're not talking about padding, but vertical spacing. |
|
If there are no more blockers, can I get a green check on this. |
|
Thanks for the feedback, everyone! |
|
Great work ❤️ |



What?
PR makes the following changes in the
InitPatternModalcomponent:Stackcomponent.isCleanNewPostselector directly from the state lazy-init function.z-indexvalue. See similar DataViews: Inline z-index values #78315.P.S. The code is easier to review with whitespace hidden - https://github.com/WordPress/gutenberg/pull/79190/changes?w=1.
Testing Instructions
https://example.test/wp-admin/edit.php?post_type=wp_block.Testing Instructions for Keyboard
Same.
Use of AI Tools
None.