-
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
Block Switcher Preview: Adjust the position and enable pattern list preview in mobile viewport #63512
Conversation
…w in mobile viewport
cef6fd1
to
cac4e19
Compare
Size Change: -196 B (-0.01%) Total Size: 1.75 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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @albanyacademy. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
<div className="block-editor-block-switcher__popover-preview-container"> | ||
<Popover | ||
className="block-editor-block-switcher__popover-preview" | ||
placement={ isMobile ? 'bottom' : 'right-start' } |
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.
For mobile layouts only, displays the pattern preview popover at the bottom.
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.
This works really well for me, thanks! I'm not 100% sure the patterns preview on mobile is perfect at the bottom, but of course in trunk is broken. Let's land this and explore an improvement for that, if needed in the future.
@ntsekouras Thanks for the review! |
…w in mobile viewport (WordPress#63512) Unlinked contributors: albanyacademy. Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org>
@albanyacademy mind sharing your WordPress.org username so I can ensure its included in the 6.7 credits listing? |
Fixes #51309
What?
This PR solves two problems:
Why?
Preview is not positioned correctly on narrow browser width
The
Popover
component hasflip
prop to flip the popover when there isn't enough space by default. But the anchor element is a "point" and is fixed to the top right of the switcher popover:As a result, the preview popover will flip based on this anchor and overlap the switcher popover if there is not enough space to the right.
Pattern preview is not displayed in the mobile viewport, so conversion to pattern is not possible
On mobile viewports, the preview popover is hidden via CSS, so clicking "Patterns" from the switcher popover does nothing.
If we're transforming blocks, we don't necessarily need the preview popover, but for patterns, we need the preview popover because we need to select any pattern from the pattern list.
How?
Preview is not positioned correctly on narrow browser width
Position the preview popover's anchor so that it's equal in size and position to the switcher popover:
This will position the preview popover to the left of the switcher popover if there's not enough space to the right.
Pattern preview is not displayed in the mobile viewport, so conversion to pattern is not possible
On mobile viewports, there isn't enough space to display the preview popover on either the left or right side. As a workaround, place the preview popover below the switcher popover:
Testing Instructions
Screenshots or screencast
1e2a79a1d65644c05b14536697649a04.mp4