-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select last section if parent section doesn't exist #61002
Conversation
Size Change: +8 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Pushed a small refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @draganescu! The fix works as expected.
Note: The logic inside the mode === 'zoom-out'
block is becoming a little bit hard to follow. It might be a time for minor refactoring + adding comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found another issue that seems to be related.
Steps to reproduce.
- Open the Site Editor.
- Open the Inserter > Patterns > Any category.
- Click on the canvas in Zoomed-out view.
- Notice that the Insert isn't closed, and the Patterns tab is missing.
- Toggle inserter.
- Notice that Media tab is also missing
Screenshot
CleanShot.2024-04-23.at.18.55.47.mp4
@scruffian, that sounds good. Could you add details on how it's different from the issue @draganescu resolved? |
What?
Fixes #60972
Why?
Selecting a category from the inserter patterns tab puts the editor in zoom out mode. Since in zoom out mode block selection is disabled and we default to "section" selection, we need to manage what is selected.
There is some logic to decide what to select in
__unstableSetEditorMode
which is an action in the block editor store, so when zoom out is activated:The bug in #60972 happens because we didn't consider that a selected block may have an undefined parent section (the root block doesn't).
How?
Fixes
__unstableSetEditorMode
to also select the last section, if the currently selected block does not have a valid parent section.Testing Instructions
main
Testing Instructions for Keyboard
n/a
Screenshots or screencast
n/a
(*) "last root block", we expect that in a template we'd have a list of patterns or other grouped blocks, so if they're not in a
main
group they're considered sections themselves.