-
Notifications
You must be signed in to change notification settings - Fork 846
Paid Blocks Nudge: Fix Border by Injecting has-warning Style #13019
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: August 6, 2019. |
|
ockham, Your synced wpcom patch D30305-code has been updated. |
|
ockham, Your synced wpcom patch D30305-code has been updated. |
simison
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.
|
Ugh my bad. I'll try to find a fix... |
|
Might be easiest to keep this implementation and override the background color + layer that stops pointer interactions? |
|
ockham, Your synced wpcom patch D30305-code has been updated. |
Exactly my plan 👍 |
|
ockham, Your synced wpcom patch D30305-code has been updated. |
|
More fun: The relevant styling isn't only https://github.com/WordPress/gutenberg/blob/c5e8784799f4e0f4d0891f52fae95375f43b76f7/packages/block-editor/src/components/block-list/style.scss#L219-L224 but also https://github.com/WordPress/gutenberg/blob/c5e8784799f4e0f4d0891f52fae95375f43b76f7/packages/block-editor/src/components/block-list/style.scss#L252-L261 which generates a transparent pseudo-element that eats up cursor focus, and tints its what's behind it grey. |
|
ockham, Your synced wpcom patch D30305-code has been updated. |
Issue found in review should be fixed now
extensions/shared/with-has-warning-is-interactive-class-names/style.scss
Show resolved
Hide resolved
| if ( requiredPlan ) { | ||
| addFilter( | ||
| 'editor.BlockListBlock', | ||
| `jetpack/${ name }-with-has-warning-is-interactive-class-names`, |
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.
Haha that's a mouthful!
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.
Yeah, same for the component name 😬 Happy to change it something more palatable!
simison
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.
Looking good and works fabulously well!
| BlockListBlock => props => ( | ||
| <BlockListBlock | ||
| { ...props } | ||
| className={ props.name === name ? 'has-warning is-interactive' : '' } |
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-interactive isn't a core class, right? Therefore I'd jetpack-prefix it. Not a blocker tho.
zinigor
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.
Works well for me, the border appears as it should.

Fixes #13007.
Fixes #13008, too 😎
Changes proposed in this Pull Request:
Paid Blocks Nudge: Fix Border by Injecting has-warning Style
Prior to this PR, we used custom styling for the
jetpack-paid-block__wrapperclass, using padding and negative margins. This lead to visual glitches such as #13007:As documented there, this is because that kind of styling doesn't play well with Gutenberg's own, which is using absolute positioning on
:beforeselectors such as.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-edit:before.block-editor-block-list__layout .block-editor-block-list__block.is-selected>.block-editor-block-list__block-edit:before.block-editor-block-list__layout .block-editor-block-list__block.has-warning .block-editor-block-list__block-edit:beforeSo ideally, we want to piggy-back on those selectors -- the
has-warningones in particular, since they do precisely what we want (also on a conceptual level). However, that's not easy from within the block, since those selectors apply to the block wrapper. Class names for that wrapper are pretty much hard-wired, and there aren't really any props to that element that we could (or should) modify to enforce the styling we want.But fortunately, there's a filter to modify those wrappers 🎉
This PR thus uses that filter to inject the
has-warningclass, fixing #13007, and allowing us to drop a bunch of custom styling.However, the
has-warningselector also adds styling to prevent user interactivity with the given block (see #13019 (comment) for details), so we need to override that behavior, since we want to ensure the user can continue to interact with the block. To that end, we add another class name,is-interactivefor increase specificity, and override the styling that would otherwise prevent user interactions.Is this a new feature or does it add/remove features to an existing part of Jetpack?
Modifies the existing paid plan nudge.
Testing instructions:
yarn build), and start Docker (yarn docker:up)docker/mu-plugins, e.g. a newly created0-blocks-upgrade.php(needs to start with<?php):define ( 'JETPACK_SHOW_BLOCK_UPGRADE_NUDGE', true );Proposed changelog entry for your changes:
(Covered by whatever we add for #12823)