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

Button Block: Can't set typography #64662

Closed
2 tasks done
shimotmk opened this issue Aug 21, 2024 · 3 comments · Fixed by #68023 · May be fixed by #64869
Closed
2 tasks done

Button Block: Can't set typography #64662

shimotmk opened this issue Aug 21, 2024 · 3 comments · Fixed by #68023 · May be fixed by #64869
Assignees
Labels
[Block] Buttons Affects the Buttons Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@shimotmk
Copy link
Contributor

Description

If typography is set for the button element in theme.json, the settings in the block will not work.

Step-by-step reproduction instructions

  1. Set Twenty Twenty-Four theme
  2. Place Button block
  3. Set the Appearance to Bold, etc.

You can see that the Appearance has not changed in either the editor screen or the front screen.

Screenshots, screen recording, code snippet

core-button

Environment info

  • WordPress 6.6.1
  • Gutenberg 19.0.0

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes
@shimotmk shimotmk added the [Type] Bug An existing feature does not function as intended label Aug 21, 2024
@t-hamano t-hamano added the [Block] Buttons Affects the Buttons Block label Aug 21, 2024
@talldan
Copy link
Contributor

talldan commented Aug 21, 2024

Confirmed, I can also reproduce this.

It looks like the block styles apply to the button wrapper wp-block-button, whereas the element styles apply to the inner element wp-element-button and that's why they take precedence.

I tested 6.5, and it was the same in that version, so it doesn't seem to be a new bug.

@aaronrobertshaw
Copy link
Contributor

@talldan hit the nail on the head.

Global styles for the button block type will also target the inner element. The button block seems to have some ad hoc styles to force inheritance but they don't seem to cover all typography styles.

For example:

.wp-block-button[style*=font-weight] .wp-block-button__link {
    font-weight: inherit;
}

There might be two options for a fix;

  1. Add some extra styles to force inheritance
  2. Update the button block to skip serialization and manually apply styles to the inner element and include a deprecation to migrate old buttons where the styles are still on the wrapper.

Option 1 might be the simplest but would need to be updated for any new typography supports added in the future.

@shimotmk
Copy link
Contributor Author

@talldan or @aaronrobertshaw
This pull request looks fine. #64869
Can you review it?

shimotmk added a commit to shimotmk/gutenberg that referenced this issue Dec 16, 2024
ramonjd added a commit that referenced this issue Dec 31, 2024
Fixes #64662. The current typography does not work correctly with the given Core Button block styles. This fix forces inner elements to inherit the styles with the exception of `writingMode` which is set on the block wrapper.

Co-authored-by: shimotmk <[email protected]>
Co-authored-by: ramonjd <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>
Co-authored-by: talldan <[email protected]>
Gulamdastgir-Momin pushed a commit to Gulamdastgir-Momin/gutenberg that referenced this issue Jan 23, 2025
Fixes WordPress#64662. The current typography does not work correctly with the given Core Button block styles. This fix forces inner elements to inherit the styles with the exception of `writingMode` which is set on the block wrapper.

Co-authored-by: shimotmk <[email protected]>
Co-authored-by: ramonjd <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>
Co-authored-by: talldan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
4 participants