-
Notifications
You must be signed in to change notification settings - Fork 538
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
Apply sx
prop to Select's parent for custom styles
#3888
Conversation
🦋 Changeset detectedLatest commit: ecefb0a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
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.
Almost there! Just a tiny change needed
src/Select.tsx
Outdated
@@ -81,6 +84,7 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>( | |||
fill: disabled ? 'GrayText' : 'FieldText', | |||
}, | |||
}, | |||
...sx, |
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.
Hi! This is 99% there.
...sx
does a shallow merge with the existing styles so it might accidentally override nested style objects. We have a merge
utility for sx that deep merges. Here is a another component that uses merge for reference.
For example, with shallow merge:
<Select sx={{
'@media screen and (forced-colors: active)': {
color: 'fg.muted'
}
}}>
...props.sx
will completely overwrite the '@media screen and (forced-colors: active)' key and remove svg 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.
Thanks! Makes sense!
Here's the format we follow for changesets:
|
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.
Looks great!
Feel free to merge it whenever you're ready!
Closes #3599
This PR fixes a bug where the
sx
prop for theSelect
component didn't have any effect.Given the following custom styles, here is the before/after:
It seems as though the custom styles need to be applied to the
TextInputWrapper
component rather than theStyledSelect
component, but I'm wondering if there are any drawbacks or complications from applying all of the custom styles to this element.Rollout strategy
Testing & Reviewing
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.