Skip to content
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

WhatsApp block: Increase specificity for background styling #19356

Merged
merged 4 commits into from
Apr 12, 2021

Conversation

stacimc
Copy link
Contributor

@stacimc stacimc commented Mar 30, 2021

Fixes #18688

Changes proposed in this Pull Request:

  • When the WhatsApp button is focused on the frontend, the icon disappears. This is caused by a style from the Twenty Twenty One theme applying a background style that overrides the block style when focused. This PR adds a selector with higher specificity to make sure the background styling is not overridden.
  • Also a small tweak to the editor styles to correctly center the button text and remove unnecessary bottom border in some themes.

Notes
Adding the :focus selector was not enough to increase the specificity; I also had to select on the parent div.wp-block-jetpack-whatsapp-button. I added this in a separate selector rather than applying to all of the WhatsApp button styles to prevent the styling from breaking if the user deletes the parent block in the code editor.

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Sync this branch.
  • Activate the Twenty Twenty One theme.
  • Create a new post and insert a WhatsApp button block.
  • View the post on the frontend.
  • Click on the button and observe that the icon does not disappear.
  • Clicking will redirect the page, so you can also test by forcing the ":focus" state in the Chrome devtools or Tabbing to the component in order to focus it.

Before
Screen Shot 2021-03-30 at 4 16 59 PM

After
Screen Shot 2021-03-30 at 4 17 29 PM

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello stacimc! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D59526-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Mar 30, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 30, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: April 13, 2021.
  • Scheduled code freeze: April 6, 2021.

andrewserong
andrewserong previously approved these changes Mar 31, 2021
Copy link
Member

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good to me @stacimc and tests nicely, I tried it with a couple of different themes applied to confirm it doesn't regress anything.

In the process I found a couple of subtle other styling issues with the WhatsApp block. In the editor with Seedlet or Spearhead themes, the line height gets overridden and the text is slightly off vertically within the editor (but not on the front end). It also adds a 1px bottom border to the button:

image

If I add the following to the main a.whatsapp-block__button selector, I can get it back to looking normal in the editor:

line-height: 36px; // 20px font size + 16 px padding
border: none;

image

Not sure if you want to include it in this PR, if not I'm happy to open up a separate PR for it 🙂

@andrewserong andrewserong added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Mar 31, 2021
@stacimc
Copy link
Contributor Author

stacimc commented Mar 31, 2021

Thanks @andrewserong, well spotted. Added!

@stacimc stacimc removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Mar 31, 2021
Copy link
Member

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding in the extra CSS @stacimc! Looks like the CI jobs are complaining that the PR needs a rebase, but it's testing well for me now, across Twenty Twenty, Twenty Twenty One, Spearhead, Seedlet, Barnsbury and Mayland themes.

I notice that the vertical position of the text feels slightly different on each of these themes, which is most likely normal... if we wanted to, we could possibly tweak the line-height down slightly to 32px to even out the difference between some of the themes, but I think I might have been staring at this button for too long now, it's probably fine how it is 😅

@andrewserong andrewserong added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Team Review labels Apr 1, 2021
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 🚢

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Apr 9, 2021
@jeherve jeherve added this to the jetpack/9.7 milestone Apr 9, 2021
@jeherve jeherve enabled auto-merge (squash) April 9, 2021 10:42
@jeherve jeherve merged commit 7b92086 into master Apr 12, 2021
@jeherve jeherve deleted the fix/whatsapp-button-focused-style branch April 12, 2021 18:55
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 12, 2021
@github-actions
Copy link
Contributor

Great news! One last step: head over to your WordPress.com diff, D59526-code, and commit it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@andrewserong
Copy link
Member

r224577-wpcom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Send a message [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WhatsApp Block: In the Twenty Twenty-One theme, the focus style overrides the icon in the WhatsApp button
4 participants