-
Notifications
You must be signed in to change notification settings - Fork 4.7k
DataForm: fix label colors #75730
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
Merged
+4
−2
Merged
DataForm: fix label colors #75730
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Out of curiosity, in what situations do these standard
@wordpress/componentslabels not have the standard gray-900 color, that you would have to define them explicitly here? If there are explicit color styles missing in the basic components themselves, we can address it at the source, not just in DataViews.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.
There were a few too many. Just did a quick test removing these styles and:
good:
bad:
n/a (don't have label):
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.
I guess my question is, even if each label didn't have explicit color styles out of the box, wouldn't it be easier to set
gray-900on the broader container and not on each specific label element? The labels just inherit color from the surrounding context, and the reason they have been generally fine without a explicit color is becausegray-900is the default text color throughout the app. We assume that there is an intentional, default text color set on the overall app. So at first glance, it seems that it would be much simpler to set the color on.dataforms-layouts-regular__fielditself, for example (or probably an even wider scope).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.
That's a good thought, thanks for sharing. I tried the CSS cascade approach (using the red color, for making it clear) and this is what happens:
Screen.Recording.2026-02-25.at.09.59.10.mov
The reason is that the label element for input and select controls have a emotion style attached (
color: var(--wp-components-color-foreground, #1e1e1e);) and so the CSS cascade doesn't work for them.There's a few ways forward here: either we use the same approach as input/select or we use CSS cascade. I suppose the new DS theme styles can also work here. I'm not opinionated about any particular approach and trust your expertise. Though it seems a bigger effort for a place other than this PR that addresses a bugfix for 7.0 beta.
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.
And I thought that would be fine in this context, because I thought you wanted all the labels to be
gray-900(which is equivalent tovar(--wp-components-color-foreground, #1e1e1e)). So the cascade won't apply to input and select, but that doesn't matter because they are alreadygray-900.Uh oh!
There was an error while loading. Please reload this page.
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.
That's correct, but only coincidentally. They only fallback to the proper color if
--wp-components-color-foregroundis unavailable. What if we select/input controls change color? etc. The components are not consistent in a way that generates trust for DataForm as a consumer to rely on them. I'd rather be cautious and prevent regressions before they happen.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 we changed the label colors for select/input but not for all the other controls, that is a bug, so you can report it 😄
Anyway my comments are non-blocking, just mainly wanted to figure out if there's anything obviously missing from the
@wordpress/componentsstyles.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.
I'm mostly a bit worried about some having style hooks (
--wp-components-color-foreground) and some others not, and how that may impact consumers of DataForm. It'd be ideal that there's consistency among controls, so if that--wp-components-color-foregroundchanges, it impacts all controls rather than just some. I suppose this would be easier with the new DS theme styles :)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.
And to be clear,
--wp-components-color-*are never actually defined anywhere in any official way (aside from like one progress bar in the Gutenberg app), and are completely experimental tokens that will be superseded by the official DS theme tokens pretty soon. So you can basically regard those as equivalent to their fallback values.