-
Notifications
You must be signed in to change notification settings - Fork 798
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
Jetpack Button Block: Ensure block enqueues core Button block styles as a dependency #19595
Jetpack Button Block: Ensure block enqueues core Button block styles as a dependency #19595
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
@@ -39,10 +39,15 @@ function register_block() { | |||
function render_block( $attributes, $content ) { | |||
$save_in_post_content = get_attribute( $attributes, 'saveInPostContent' ); | |||
|
|||
if ( Blocks::is_amp_request() ) { |
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.
Note: this AMP is removed here. Previously we only loaded the block's style if it's an AMP request because the only styles we needed to load were targeted for AMP. We now have a style rule that should be applied when not in an AMP request, so I think the conditional is no longer needed.
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 tested mostly well for me, and looks like it will allow us to handle some of the related issues (Mailchimp for example) more easily!
I tested with Contact Form, Mailchimp, Donations, Payments, and Premium Content. I tried to test with Pay with Paypal but it is currently pretty broken/being worked on. A couple of things I noticed:
Button alignment does not appear to be working correctly. In FSE for example, I inserted a Contact Form and tried to make the button 50% width and center-aligned. The width applies but the alignment does not:
I also noticed that the Premium Content buttons are stacked on top of each other, and width/alignment do not function correctly:
Do you think it would be worth also enqueuing the Buttons
block styles as well? I believe that would at least fix the vertical stacking on the Premium Content buttons, although I'm inclined to say most of the above should be separate issues from this PR -- it looks like the styles for alignment classes aren't all loaded, and some of the Premium Content issues appear to be block-specific.
The base styles should instead come from the jetpack button (#19595)
Thanks for testing this out @stacimc! I'll have a play around with enqueuing the Buttons block styles, too. I think if the Jetpack Button block was designed to depend on the styling from those blocks, it's fair to enqueue them as well. |
…ock, include editor styles for right alignment
@stacimc thanks again for the thorough testing! I've updated this to also enqueue the For the issue with I've also added a CSS rule for right alignment for the Jetpack Button block within the editor (I noticed right alignment wasn't displaying correctly for e.g. the button block in the Mailchimp block). There are a bunch of other little issues with button alignment, but like you mention, these are probably better tackled as separate issues/PRs for the individual blocks affected. After this PR lands, I'm happy to work through some of those to fix them up a bit. It might step slightly outside of scope for FSE strictly-speaking, but it'd be good to get some of them sorted. Do you think this PR is looking okay now for a first pass, or do you think it needs tweaking / addressing other issues too? |
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 looks great and will have a big impact 🥳 Tests well for me and I totally agree about the rest being handled in separate PRs. Thanks!
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 looks good to me. 🚢
Great news! One last step: head over to your WordPress.com diff, D60465-code, and commit it. Thank you! |
The base styles should instead come from the jetpack button (#19595)
r224816-wpcom |
@@ -1,3 +1,7 @@ | |||
.amp-wp-article .wp-block-jetpack-button { | |||
color: #ffffff; | |||
} | |||
|
|||
.wp-block-jetpack-button button { | |||
border: inherit; |
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 change seems to be related to Automattic/themes#5776 (comment)
As tracked in #19464 the Jetpack Button block depends on styles from the core Button block (via the class name
.wp-block-button__link
. In an FSE theme like TT1-blocks, no styles are provided to override the button block styling, so it becomes apparent that when no core Button block is inserted into a template part, then the Jetpack button block appears unstyled.To address this, we can ensure that the core Button block styles are always enqueued when a Jetpack Button block is rendered on the server.
Possible fix for #19464 and related to #19504
Changes proposed in this Pull Request:
inherit
), to avoid the browser default button border from being addedJetpack product discussion
Does this pull request change what data or activity we track or use?
No
Ensuring no regressions on a non-FSE site, checking that outline style and custom colours still works:
Testing instructions: