Divider: Restore lower border specificity#79534
Conversation
|
It's unfortunate that we need to revert to this, One alternative is to use |
|
Size Change: +4 B (0%) Total Size: 7.5 MB 📦 View Changed
|
ed84796 to
eedfb49
Compare
|
|
||
| ### Bug Fixes | ||
|
|
||
| - `Divider`: Restore lower-specificity border styles so custom border colors can override the default divider color. ([#79534](https://github.com/WordPress/gutenberg/pull/79534)) |
There was a problem hiding this comment.
Necessary, since the Emotion refactor is part of previous release
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @foufounounou680-svg. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
|
Flaky tests detected in 0fdd286. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28224299095
|
|
Thanks for the PR! Is it possible to apply .divider {
&:where([aria-orientation="vertical"]) {
}
} |
Done! Code diff is a lot cleaner, too |
This comment was marked as spam.
This comment was marked as spam.
| // Keep the horizontal selector at the pre-#79444 specificity so existing custom | ||
| // border color overrides continue to win. | ||
| &:where([aria-orientation="horizontal"]) { | ||
| border-block-end: 1px solid currentColor; |
There was a problem hiding this comment.
Maybe the root cause is that the specific selector defines also the border style and color, although it doesn't need to. What if we moved up everything we can?
.divider {
border-width: 0;
border-style: solid;
border-color: currentColor;
.horizontal {
border-width-block-end: 1px;
}
.vertical {
border-with-inline-end: 1px;
}
}Does that solve the conflict with .interface-complementary-are hr? From #79444 (comment) it's not entirely clear to me which selector should win.
There was a problem hiding this comment.
I like this approach.
There was a problem hiding this comment.
Although I don't think it's safe — for example, complementary area overrides the whole border property (ie. border-bottom: 1px solid #f0f0f0), and if we're trying to make the most backwards compatible change, I believe we should keep the previous behaviour, ie. allow consumers to overrides the whole border, not just its color.
I'll switch back to the solution proposed here
There was a problem hiding this comment.
complementary area overrides the whole
borderproperty
It should still win and apply its color, because the selector is "longer": two classes instead of one.
The only thing that is not back-compatible and really requires :where would be the 1px border color. If .interface-complementary-are hr specified 2px, it would no longer win as it did before.
* Divider: Restore lower border specificity * Divider: Add specificity fix changelog * Divider: Lower vertical selector specificity * Divider: Lower horizontal selector specificity * Divider: Explain horizontal specificity override * Divider: Split border color from orientation width --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Follow up to #79444 (comment)
What?
Restores
Dividercustom border overrides after the #79444 SCSS Module migration.Why?
The migration moved divider border declarations into orientation selectors such as
.divider[aria-orientation="horizontal"]. That made the default border styles more specific than legacyhroverrides, such as complementary-area rules that set a full border shorthand.How?
Keeps the separate horizontal and vertical orientation blocks from trunk, but wraps both orientation selectors in
:where().This preserves the orientation-specific CSS structure while removing the additional attribute-selector specificity, so existing border overrides can continue to win.
Testing Instructions
npm run storybook:dev.Components / Divider.hrwith a custom border shorthand, confirm the custom border style wins over the Divider default border style.Testing Instructions for Keyboard
No keyboard-specific behavior changed.
Dividerremains a non-interactive separator.Screenshots or screencast
N/A: CSS specificity regression fix only.
Use of AI Tools
This PR was prepared with assistance from OpenAI Codex and reviewed before publishing.