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
Add support for style merging in mergeProps #6032
base: main
Are you sure you want to change the base?
Conversation
let {elementType: ElementType = 'div', style, draggable, ...otherProps} = props; | ||
let {elementType: ElementType = 'div', draggable, ...otherProps} = props; | ||
let {pressProps} = usePress(otherProps); | ||
return <ElementType {...pressProps} style={style} tabIndex="0" draggable={draggable}>{ElementType !== 'input' ? 'test' : undefined}</ElementType>; | ||
return <ElementType {...pressProps} tabIndex="0" draggable={draggable}>{ElementType !== 'input' ? 'test' : undefined}</ElementType>; |
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.
see: #2457 (comment)
@@ -12,7 +12,7 @@ | |||
|
|||
import clsx from 'clsx'; | |||
import {mergeIds} from '../src/useId'; | |||
import {mergeProps} from '../'; | |||
import {mergeProps} from '../src/mergeProps'; |
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 changed the import path because the changes were not reflected after saving.
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 for the PR. Unfortunately, this has messed with some of our VRT https://www.chromatic.com/test?appId=5f0dd5ad2b5fc10022a2e320&id=65ee2607b7324b7ea6d3dc47
fortunately, I think the fix should be mostly contained to https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/story-utils/src/GeneratePowerset.tsx
I think one could argue this is a breaking change as well. At this point, people might be relying on the fact that styles are not merged. |
This is a good point. If it suddenly started merging, people could suddenly have extra styles coming through. Do we actually want to do this? we could add an argument that describes how to merge the props, either a simple boolean for merge styles, or more complex, a method to give control of the merge... Unless we do it by default though, it doesn't really help with instances such as #2457 (comment) because the user has to realize that there two competing style objects. We'd discussed a version of mergeProps which does memo'ing, maybe we handle it there? waves hands towards the future |
Closes #2507
β Pull Request Checklist:
π Test Instructions:
Add the following code to Storybook and verify that styles are merged correctly.
π§’ Your Project: