-
Notifications
You must be signed in to change notification settings - Fork 843
Block: OpenTable: Add a warning if width is set to anything other than wide if style is wide #15323
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
Conversation
|
Caution: This PR has changes that must be merged to WordPress.com |
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: May 5, 2020. |
extensions/blocks/opentable/edit.js
Outdated
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.
Is there a reason for this? I'd rather show the warning all the time (when style is wide and align isn't), so that the user is always aware of it.
Otherwise, they might save the post, come back later and have no idea why it looks wonky.
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 was just assuming that if they decided to ignore the warning and save it, then they had a reason for doing so, so didn't wanted to be reminded every time they loaded the page ... but you maybe you are correct and we should hassle them every time as it will obviously be broken, so have taken this out for now.
extensions/blocks/opentable/edit.js
Outdated
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 needs a few more checks!
- The notice shouldn't appear on the wide style preview in the sidebar.
- The notice shouldn't appear on the placeholder, where we already use
noticeUIfor embed errors.
I've had success with this:
const { noticeOperations } = props;
const { __isBlockPreview, align, rid, style } = attributes;
useEffect( () => {
noticeOperations.removeAllNotices();
if ( ! isEmpty( rid ) && ! __isBlockPreview && 'wide' === style && 'wide' !== align ) {
noticeOperations.createNotice( {
status: 'warning',
content: __( 'Warning' ),
} );
}
}, [ __isBlockPreview, align, noticeOperations, rid, style ] );Notes:
isEmpty( rid )is what we use for determining if the block is in placeholder state. Since we use it a few times, we might as well assign it to a more clear variable, e.g.const isPlaceholder = empty( rid ).__isBlockPreviewis part of our ownBlockStylesSelectorcomponent, and turns out to be super handy in this case!- We need to pass the actual used variables to the hook, not just the
attributesobject, or we would trigger this every time any attribute changes.
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.
Ahh, thanks for all this extra detail ... I still have a lot to learn about the jetpack blocks, been stuck in the back end for too long! I have made all these changes and seems much more robust now.
extensions/blocks/opentable/edit.js
Outdated
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 block is styled in a bit of a complicated way, with an overlay setting its height.
If we render the notice here, the embed would overflow outside the overlay.
You can observe this in one of the PR gifs, where the embed moves behind the inserter button.
I've tried a few options, and had success with moving it outside the edit wrapper.
<>
{ noticeUI }
<div className={ editClasses }>
{ ! isEmpty( rid ) && inspectorControls }
{ ! isEmpty( rid ) ? blockPreview() : blockPlaceholder }
</div>
</>Awkwardly enough, when the block is centrally aligned, the text of the notice is centered as well.
We might want to fix it in CSS. 🤔
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.
Yep, this is much gooder thanks ... fixed the centre alignment too.
…an wide if style is wide
129aceb to
516fbb1
Compare
|
glendaviesnz, Your synced wpcom patch D41472-code has been updated. |
|
glendaviesnz, Your synced wpcom patch D41472-code has been updated. |
|
glendaviesnz, Your synced wpcom patch D41472-code has been updated. |
|
thanks @Copons, ready for another review I think. |
|
glendaviesnz, Your synced wpcom patch D41472-code has been updated. |
|
Thanks for the updates @glendaviesnz! Anyway, while testing this again, I've noticed that the warning shows up with We have limited powers over the embed, but I guess there might some things we can do here:
What do you think? 🤔 |
|
glendaviesnz, Your synced wpcom patch D41472-code has been updated. |
|
@Copons - thanks for fixing the lint issues - I have the pre-commit hooks working again, so hopefully less of those now! Nice catch on the full width - have added support for that, and also updated the message (which probably now should actually say, "don't use the wide style cause it sucks, it is only there so we have an even number of styles to show!"). I tried setting overflow to auto, but this only worked on 'centre' align for some reason that I was unable to work out. Feel free to have go at this and update the PR if you get it working. |
Copons
left a comment
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 couldn't figure out a way to show scrollbars either. I think it's something that needs to be done inside the iframe. 😞
Regardless, this LGTM!
jeherve
left a comment
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 well in my tests. 🚢

Fixes #14857
Currently the OpenTable
widestyle does not display well in themes if the block alignment is set to anything other thanwidealso. If a user selects thewidestyle the alignment is automatically set back towide, but the user can change this using the block alignment toolbar option.There is currently no way to disable particular options in the alignment toolbar on the fly, so this PR instead adds a warning notice to at least alert the user to the fact that their current style/align combination may cause display issues.
Changes proposed in this Pull Request:
Testing instructions:
Add this PR to your local Jetpack dev env
Add an OpenTable block
Try setting the block style to wide, and then set the block alignment to something other than wide
Make sure the warning notice appears and is dismissible
Make sure the notice doesn't appear on page reload of those alignment settings are saved
Make sure the notice disappears if the alignment is set back to wide
Before:
After:
Proposed changelog entry for your changes: