-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 Styles: check for existence of scroll container #37010
Conversation
Marking as a bugfix to Backport into 5.9 if that's still viable. It's not a pretty one. |
Size Change: +6 B (0%) Total Size: 1.1 MB
ℹ️ View Unchanged
|
const scrollTop = scrollContainer?.scrollTop || 0; | ||
// Add the hardcoded equivalent of the container's right position. | ||
setContainerScrollTop( scrollTop + 16 ); |
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.
Ignorable comment: in the contexts where scrollContainer
is null, do we still need the 16?
const scrollTop = scrollContainer?.scrollTop || 0; | |
// Add the hardcoded equivalent of the container's right position. | |
setContainerScrollTop( scrollTop + 16 ); | |
if( scrollContainer ) { | |
// Add the hardcoded equivalent of the container's right position. | |
setContainerScrollTop( scrollContainer.scrollTop + 16 ); | |
} |
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 👀 @alshakero !
: in the contexts where scrollContainer is null, do we still need the 16
Not really, but I don't see any problem with leaving it at 16
. Normally, 16
(the same as the right
value in the CSS) is the minimum top position value we need to display the block preview.
If the scrollContainer
isn't there, we can assume the block preview won't be rendered at all since the Slot component lives within it.
That's the theory 😆
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.
Fix seems straightforward and this tests well for me! 👍
Tested to confirm the bug on trunk and verified that it works on the branch. Previews are still working well in the block editor. LGTM!
4eb6e15
to
1b942f4
Compare
Just realized it's not even in 11.9. Removing label. |
* Let's check if the scrollContainer can be found before trying to use its property `scrollTop`. * Moving default top position to a const and moving the comment.
Hey folks, a few guidelines about patch releases:
Thanks :) |
Okay, thanks for the info. I'll re-add the beta label, and also add it to the 12.1 milestone. |
Thanks ❤️ |
Thanks for confirming @noisysocks 🙇 |
Resolves #36999
Description
Where a block has block styles, the Block Styles component throws an error when adding it as a widget in the Customizer.
To avoid this, let's check if the scrollContainer can be found before trying to use its property
scrollTop
.Testing
First checkout the latest version of trunk.
I'm using TwentyTwenty theme to test.
/wp-admin/customize.php?return=%2Fwp-admin%2Fthemes.php
Footer #1
Repeat the same as above using this branch.
The error should not be thrown.
Props to @alshakero for documenting it.
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).