-
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
Block Editor: Prevent block styles from leaking into an inner Warning
component
#40847
Conversation
@@ -3,6 +3,7 @@ | |||
display: flex; | |||
flex-wrap: wrap; | |||
font-family: $default-font; | |||
font-size: $default-font-size; |
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.
We need to specify a fixed font-size
here as the padding property for this class is relative to the font size.
@@ -14,6 +15,10 @@ | |||
line-height: $default-line-height; | |||
font-family: $default-font; | |||
font-size: $default-font-size; | |||
text-transform: none; |
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.
Avoids changes in "Typography > Letter case".
@@ -14,6 +15,10 @@ | |||
line-height: $default-line-height; | |||
font-family: $default-font; | |||
font-size: $default-font-size; | |||
text-transform: none; | |||
letter-spacing: normal; |
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.
Avoids changes in "Typography > Letter spacing".
font-weight: normal; | ||
font-style: normal; |
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.
Avoids changes in "Typography > Appearance".
Size Change: +50 B (0%) Total Size: 1.23 MB
ℹ️ View Unchanged
|
Warning
component
This approach will require more updates when adding new block supports to Gutenberg. Maybe using a Shadow DOM could make sense here to isolate the styles? I know using Shadow DOM in React requires using imperative DOM APIs, but maybe it is worth trying? |
That's a good point. I ll try this approach in another PR. I think it makes to use the encapsulation that shadow DOM provides but we should also see how difficult that is. I don't want to create a whole new library for interfacing with WC just to solve a single problem 🙂 |
Just in case: you don't need to use WC (custom elements) to use the shadow DOM. You can attach it to a |
Oh, interesting! I did not know about this, thanks! :) |
Closing in favor of #40868 🙂 |
What?
When a block uses the
Warning
component, some block styles can leak into that component and change how it looks. This PR prevents that.Why?
It is a weird UX. Fixes #40536
How?
See comments after this description.
Testing Instructions
Just follow the same steps as in the video posted in #40536 description and check that no color or typography option affects the warning message styles.
Screenshots or screencast