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

Fix Site title: Different markup in the editor and on the frontend #29021

Merged
merged 6 commits into from
Mar 17, 2021

Conversation

aurooba
Copy link
Member

@aurooba aurooba commented Feb 16, 2021

Description

I've added the __experimentalSelector setting to block.json to specifically target both the heading and anchor tag inside the Site Title Block. To go along with that, I've wrapped the RichText component in the heading tag with its props, instead of assigning the heading tag and props to the RichText component. The RichText component is now an anchor tag to accurately reflect the same semantics and styling as the front-end.

I also tested #22483, and that error doesn't seem to exist anymore (tested it with the Twenty Twenty Blocks themes).

How has this been tested?

I tested changing the font size, colour, and heading type through Global Styles in the By Block Type tab, and checked to see it was correctly reflected on the front end.

Types of changes

Block registration includes the experimentalSelector value.
Non-breaking change to fix #28997

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@aurooba aurooba requested a review from ajitbohra as a code owner February 16, 2021 05:01
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @aurooba! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Feb 16, 2021
@gziolo gziolo added [Block] Site Title Affects the Site Title Block [Feature] Full Site Editing Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended labels Feb 16, 2021
@aurooba
Copy link
Member Author

aurooba commented Feb 16, 2021

Looks like the Compressed Size / Check (pull_request) check failed because of an npm error? Not super sure how to fix this.

Copy link
Contributor

@carolinan carolinan left a comment

Choose a reason for hiding this comment

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

I have tested this to the best of my ability and everything works as I would expect.

The markup in the editor and front looks correct to me and I saw no issues when I changed width, alignment or element (Heading level or paragraph).

Tested with the theme TT1 Blocks and the typography setting in the experimental-theme.json is applied to .wp-block-site-title, .wp-block-site-title > a and
.editor-styles-wrapper .wp-block-site-title, .editor-styles-wrapper .wp-block-site-title > a

(Before the pr, this was applied to .wp-block-site-title and .editor-styles-wrapper .wp-block-site-title respectively)

Base automatically changed from master to trunk March 1, 2021 15:45
@aurooba
Copy link
Member Author

aurooba commented Mar 8, 2021

The PR has been updated to resolve the conflict with the latest update to the block.json file for this block. :)

@aurooba
Copy link
Member Author

aurooba commented Mar 11, 2021

Thanks for the grammar check @carolinan. I missed that comma 😅

@carolinan carolinan requested a review from scruffian March 12, 2021 03:00
Copy link
Member

@aristath aristath left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@carolinan carolinan merged commit 3d9f76e into WordPress:trunk Mar 17, 2021
@github-actions
Copy link

Congratulations on your first merged pull request, @aurooba! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@@ -20,6 +20,7 @@
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalSelector": ".wp-block-site-title, .wp-block-site-title > a",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we target the "inner a" here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The goal is to change the colour of the site title, which is an anchor tag wrapped in a heading.

By default, an anchor tag does not inherit its parent's colour settings if an href attribute is present. So to change the appearance of the title we target the inner anchor.

Or well, that's what was done here. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

By default, an anchor tag does not inherit its parent's colour settings if an href attribute is present. So to change the appearance of the title we target the inner anchor.

It does break font size and transform styles for the block though. I'm reverting that here #30558 to solve these. Maybe we can just add color: inherit for the link in the style of the block?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my tests though, the color is applied properly even with the revert because it actually applies the link color (which is the right thing to do there)

Copy link
Contributor

Choose a reason for hiding this comment

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

I also tested the color in the revert and worked well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Site Title Affects the Site Title Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Site title: Different markup in the editor and on the frontend
6 participants