-
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
Zoom Out: Insert patterns at the end of the root section #60855
Conversation
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. |
Size Change: -3.74 kB (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
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.
The way code reads now is, to me:
- in zoom out mode
- if there is a section root (there always is one, last resort it's the root element
''
)- get sections
- if there is a selected block
- find and select the parent section of the selection
- if there is no selected block
- find and select the last section
- if there is no section root (should not happen?)
- and if there is a selected block
- find and select the root parent of the selection
- if there is a section root (there always is one, last resort it's the root element
There are two things weird:
- 1st from the code it seems the section root is never
null|false|0
but instead it can be empty string but empty string although it evals to falsy should not be interpreted as falsy b/c it's actually the way we identify the root element. - 2nd if we do choose to consider that w/o a main group or a post content block there is no section root, we don't treat the situation when there is no selected block and no section root.
); | ||
dispatch.selectBlock( firstSectionClientId ); | ||
} else { | ||
const lastChildSectionClientId = |
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.
const lastChildSectionClientId = | |
const lastSectionClientId = |
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.
Why remove the word child? My understanding is that this block is the last one in the main section...
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.
The main
tag group, or post content, or root element are the section root containers, and their immediate children are sections. We do not have the concept of main section and child sections. Main is only the tag name we conventionally use.
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.
Ah ok, thanks :)
If section root is an empty string then we simply don't select any block, which means that the pattern gets added to the bottom of the content. |
I updated this so that if there's no section root, we just select the last root block. |
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.
Works as expected.
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.
Thanks for fixing this, hopefully will lead to less "empty inserter" situations.
What?
When zoom out mode is invoked, but there is no block selected, the pattern inserter doesn't work. This automatically selects the last block in the root section so that when patterns are inserted in zoom out mode, they are added after the last pattern in the section root.
Why?
When zoom out mode is invoked, but there is no block selected, the pattern inserter doesn't work.
How?
If there is no block selected we automatically select the last block in the section root.
Testing Instructions
Screenshots or screencast
Apr-18-2024.12-58-19.mp4
Note
We should also scroll to the selected block but that should be a different PR.