-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Button Block: Set proper typography for inner elements #68023
base: trunk
Are you sure you want to change the base?
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -301,6 +317,7 @@ function ButtonEdit( props ) { | |||
...colorProps.style, | |||
...spacingProps.style, | |||
...shadowProps.style, | |||
...typographyProps.style, |
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.
Hmm I think the .wp-block-button__link
height of 100% is interfering with the typography setting writing-mode: vertical-rl;
I wonder if changing it to auto
would break anything else 🤔
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.
If writing-mode
is best placed still on the wrapper, we could just change the __experimentalSkipSerialization
value for typography to be an array of all the other typography features except writing mode.
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.
Good call! I didn't think of that, 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.
Thanks for wrangling this fix @shimotmk 👍
While reading through the changes I've spotted a few issues and left inline comments for those.
There also looks to be a possible opportunity to clean up the .has-custom-font-size
class. It appears that was added to allow the inner element to be forced to inherit the parent font size.
Regarding the e2e failures, there are two issues;
- The new deprecation fixture for the v12 button needs to have a Button block as the base block rather than a Buttons block
- The v10 fixture has typography styles in it so the final
.serialized.html
result for the fixture needs to have the typography classes and styles moved to the inner element.
The last point there would be cover by running npm run fixtures:regenerate
. Doing so will also leave a few other unrelated fixtures updated due to the fact their attributes have been reordered. Those changes can be discarded for this PR.
The following diff shows an example of how then fixture could be. It isn't suitable for simply committing to this PR as the fixture should cover all the typography styles (with maybe the exception of writing mode as @ramonjd highlighted).
Example diff fixing fixtures
diff --git a/test/integration/fixtures/blocks/core__button__deprecated-v10.serialized.html b/test/integration/fixtures/blocks/core__button__deprecated-v10.serialized.html
index e4c7b89c794..0bebe131629 100644
--- a/test/integration/fixtures/blocks/core__button__deprecated-v10.serialized.html
+++ b/test/integration/fixtures/blocks/core__button__deprecated-v10.serialized.html
@@ -1,3 +1,3 @@
<!-- wp:button {"fontFamily":"cambria-georgia"} -->
-<div class="wp-block-button has-cambria-georgia-font-family"><a class="wp-block-button__link wp-element-button">My button</a></div>
+<div class="wp-block-button"><a class="wp-block-button__link has-cambria-georgia-font-family wp-element-button">My button</a></div>
<!-- /wp:button -->
diff --git a/test/integration/fixtures/blocks/core__button__deprecated-v12.html b/test/integration/fixtures/blocks/core__button__deprecated-v12.html
index 03ac733e5c3..355f1c2019d 100644
--- a/test/integration/fixtures/blocks/core__button__deprecated-v12.html
+++ b/test/integration/fixtures/blocks/core__button__deprecated-v12.html
@@ -1,17 +1,3 @@
-<!-- wp:buttons {"align":"wide","layout":{"type":"flex","justifyContent":"center"}} -->
-<div class="wp-block-buttons alignwide"><!-- wp:button {"fontSize":"xx-large"} -->
-<div class="wp-block-button has-custom-font-size has-xx-large-font-size"><a class="wp-block-button__link wp-element-button">My button 1</a></div>
-<!-- /wp:button -->
-
-<!-- wp:button {"style":{"typography":{"fontStyle":"normal","fontWeight":"800"}}} -->
-<div class="wp-block-button" style="font-style:normal;font-weight:800"><a class="wp-block-button__link wp-element-button">My button 2</a></div>
-<!-- /wp:button -->
-
-<!-- wp:button {"style":{"typography":{"letterSpacing":"39px"}}} -->
-<div class="wp-block-button" style="letter-spacing:39px"><a class="wp-block-button__link wp-element-button">My button 3</a></div>
-<!-- /wp:button -->
-
-<!-- wp:button {"tagName":"button","style":{"typography":{"letterSpacing":"39px"}}} -->
-<div class="wp-block-button" style="letter-spacing:39px"><button type="button" class="wp-block-button__link wp-element-button">My button 4</button></div>
-<!-- /wp:button --></div>
-<!-- /wp:buttons -->
+<!-- wp:button {"fontSize":"xx-large","style":{"typography":{"fontStyle":"normal","fontWeight":"800","letterSpacing":"39px"}}} -->
+<div class="wp-block-button has-custom-font-size has-xx-large-font-size" style="font-style:normal;font-weight:800;letter-spacing:39px"><a class="wp-block-button__link wp-element-button">My Button</a></div>
+<!-- /wp:button -->
\ No newline at end of file
diff --git a/test/integration/fixtures/blocks/core__button__deprecated-v12.json b/test/integration/fixtures/blocks/core__button__deprecated-v12.json
index b6cab91f0d5..7fd537b6575 100644
--- a/test/integration/fixtures/blocks/core__button__deprecated-v12.json
+++ b/test/integration/fixtures/blocks/core__button__deprecated-v12.json
@@ -1,72 +1,20 @@
[
{
- "name": "core/buttons",
+ "name": "core/button",
"isValid": true,
"attributes": {
- "align": "wide",
- "layout": {
- "type": "flex",
- "justifyContent": "center"
+ "tagName": "a",
+ "type": "button",
+ "text": "My Button",
+ "fontSize": "xx-large",
+ "style": {
+ "typography": {
+ "fontStyle": "normal",
+ "fontWeight": "800",
+ "letterSpacing": "39px"
+ }
}
},
- "innerBlocks": [
- {
- "name": "core/button",
- "isValid": true,
- "attributes": {
- "tagName": "a",
- "type": "button",
- "text": "My button 1",
- "fontSize": "xx-large"
- },
- "innerBlocks": []
- },
- {
- "name": "core/button",
- "isValid": true,
- "attributes": {
- "tagName": "a",
- "type": "button",
- "text": "My button 2",
- "style": {
- "typography": {
- "fontStyle": "normal",
- "fontWeight": "800"
- }
- }
- },
- "innerBlocks": []
- },
- {
- "name": "core/button",
- "isValid": true,
- "attributes": {
- "tagName": "a",
- "type": "button",
- "text": "My button 3",
- "style": {
- "typography": {
- "letterSpacing": "39px"
- }
- }
- },
- "innerBlocks": []
- },
- {
- "name": "core/button",
- "isValid": false,
- "attributes": {
- "tagName": "button",
- "type": "button",
- "text": "My button 4",
- "style": {
- "typography": {
- "letterSpacing": "39px"
- }
- }
- },
- "innerBlocks": []
- }
- ]
+ "innerBlocks": []
}
]
diff --git a/test/integration/fixtures/blocks/core__button__deprecated-v12.parsed.json b/test/integration/fixtures/blocks/core__button__deprecated-v12.parsed.json
index 466b53ae00e..542817c8428 100644
--- a/test/integration/fixtures/blocks/core__button__deprecated-v12.parsed.json
+++ b/test/integration/fixtures/blocks/core__button__deprecated-v12.parsed.json
@@ -1,84 +1,20 @@
[
{
- "blockName": "core/buttons",
+ "blockName": "core/button",
"attrs": {
- "align": "wide",
- "layout": {
- "type": "flex",
- "justifyContent": "center"
+ "fontSize": "xx-large",
+ "style": {
+ "typography": {
+ "fontStyle": "normal",
+ "fontWeight": "800",
+ "letterSpacing": "39px"
+ }
}
},
- "innerBlocks": [
- {
- "blockName": "core/button",
- "attrs": {
- "fontSize": "xx-large"
- },
- "innerBlocks": [],
- "innerHTML": "\n<div class=\"wp-block-button has-custom-font-size has-xx-large-font-size\"><a class=\"wp-block-button__link wp-element-button\">My button 1</a></div>\n",
- "innerContent": [
- "\n<div class=\"wp-block-button has-custom-font-size has-xx-large-font-size\"><a class=\"wp-block-button__link wp-element-button\">My button 1</a></div>\n"
- ]
- },
- {
- "blockName": "core/button",
- "attrs": {
- "style": {
- "typography": {
- "fontStyle": "normal",
- "fontWeight": "800"
- }
- }
- },
- "innerBlocks": [],
- "innerHTML": "\n<div class=\"wp-block-button\" style=\"font-style:normal;font-weight:800\"><a class=\"wp-block-button__link wp-element-button\">My button 2</a></div>\n",
- "innerContent": [
- "\n<div class=\"wp-block-button\" style=\"font-style:normal;font-weight:800\"><a class=\"wp-block-button__link wp-element-button\">My button 2</a></div>\n"
- ]
- },
- {
- "blockName": "core/button",
- "attrs": {
- "style": {
- "typography": {
- "letterSpacing": "39px"
- }
- }
- },
- "innerBlocks": [],
- "innerHTML": "\n<div class=\"wp-block-button\" style=\"letter-spacing:39px\"><a class=\"wp-block-button__link wp-element-button\">My button 3</a></div>\n",
- "innerContent": [
- "\n<div class=\"wp-block-button\" style=\"letter-spacing:39px\"><a class=\"wp-block-button__link wp-element-button\">My button 3</a></div>\n"
- ]
- },
- {
- "blockName": "core/button",
- "attrs": {
- "tagName": "button",
- "style": {
- "typography": {
- "letterSpacing": "39px"
- }
- }
- },
- "innerBlocks": [],
- "innerHTML": "\n<div class=\"wp-block-button\" style=\"letter-spacing:39px\"><button type=\"button\" class=\"wp-block-button__link wp-element-button\">My button 4</button></div>\n",
- "innerContent": [
- "\n<div class=\"wp-block-button\" style=\"letter-spacing:39px\"><button type=\"button\" class=\"wp-block-button__link wp-element-button\">My button 4</button></div>\n"
- ]
- }
- ],
- "innerHTML": "\n<div class=\"wp-block-buttons alignwide\">\n\n\n\n\n\n</div>\n",
+ "innerBlocks": [],
+ "innerHTML": "\n<div class=\"wp-block-button has-custom-font-size has-xx-large-font-size\" style=\"font-style:normal;font-weight:800;letter-spacing:39px\"><a class=\"wp-block-button__link wp-element-button\">My Button</a></div>\n",
"innerContent": [
- "\n<div class=\"wp-block-buttons alignwide\">",
- null,
- "\n\n",
- null,
- "\n\n",
- null,
- "\n\n",
- null,
- "</div>\n"
+ "\n<div class=\"wp-block-button has-custom-font-size has-xx-large-font-size\" style=\"font-style:normal;font-weight:800;letter-spacing:39px\"><a class=\"wp-block-button__link wp-element-button\">My Button</a></div>\n"
]
}
]
diff --git a/test/integration/fixtures/blocks/core__button__deprecated-v12.serialized.html b/test/integration/fixtures/blocks/core__button__deprecated-v12.serialized.html
index 2df6789245e..1b18b70facc 100644
--- a/test/integration/fixtures/blocks/core__button__deprecated-v12.serialized.html
+++ b/test/integration/fixtures/blocks/core__button__deprecated-v12.serialized.html
@@ -1,17 +1,3 @@
-<!-- wp:buttons {"align":"wide","layout":{"type":"flex","justifyContent":"center"}} -->
-<div class="wp-block-buttons alignwide"><!-- wp:button {"fontSize":"xx-large"} -->
-<div class="wp-block-button has-custom-font-size"><a class="wp-block-button__link has-xx-large-font-size wp-element-button">My button 1</a></div>
+<!-- wp:button {"fontSize":"xx-large","style":{"typography":{"fontStyle":"normal","fontWeight":"800","letterSpacing":"39px"}}} -->
+<div class="wp-block-button has-custom-font-size"><a class="wp-block-button__link has-xx-large-font-size wp-element-button" style="font-style:normal;font-weight:800;letter-spacing:39px">My Button</a></div>
<!-- /wp:button -->
-
-<!-- wp:button {"style":{"typography":{"fontStyle":"normal","fontWeight":"800"}}} -->
-<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="font-style:normal;font-weight:800">My button 2</a></div>
-<!-- /wp:button -->
-
-<!-- wp:button {"style":{"typography":{"letterSpacing":"39px"}}} -->
-<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="letter-spacing:39px">My button 3</a></div>
-<!-- /wp:button -->
-
-<!-- wp:button {"tagName":"button","style":{"typography":{"letterSpacing":"39px"}}} -->
-<div class="wp-block-button" style="letter-spacing:39px"><button type="button" class="wp-block-button__link wp-element-button">My button 4</button></div>
-<!-- /wp:button --></div>
-<!-- /wp:buttons -->
I hope that helps 🤞
@@ -301,6 +317,7 @@ function ButtonEdit( props ) { | |||
...colorProps.style, | |||
...spacingProps.style, | |||
...shadowProps.style, | |||
...typographyProps.style, |
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.
If writing-mode
is best placed still on the wrapper, we could just change the __experimentalSkipSerialization
value for typography to be an array of all the other typography features except writing mode.
test/integration/fixtures/blocks/core__button__deprecated-v12.html
Outdated
Show resolved
Hide resolved
@ramonjd @aaronrobertshaw I adjusted the attributes and made core__button__deprecated-v12.html into a single button block. However, the data for the fourth letterSpacing setting in core__button__deprecated-v12.html cannot be migrated. Why is that?🤔 |
I'm not following this comment sorry. It looks fine to me in the lastest commit. The current e2e failures relate to After updating the v10 fixture, all the fixture tests pass for me. Once that is sorted, there's still the issue with writing mode to fix up. |
@aaronrobertshaw |
@ramonjd @aaronrobertshaw |
@ramonjd @aaronrobertshaw |
@shimotmk the issue I flagged in my last two reviews still needs fixing.
|
@aaronrobertshaw Moved the |
Thanks for the continued work on this PR @shimotmk 🙇🏻 It looks like the mobile unit tests fails are related to the button block: https://github.com/WordPress/gutenberg/actions/runs/12429816613/job/34704026313?pr=68023#step:6:2906 |
@ramonjd |
What?
The current typography does not work correctly with the given button styles. This fix forces inner elements to inherit the styles.
Fixes #64662
related #64869
Why?
How?
Testing Instructions
You can see that the Appearance has changed on either the editor screen or the front screen.
Testing Instructions for Keyboard
Screenshots or screencast