-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Tooltip] Fix the property forwarding priority #13667
[Tooltip] Fix the property forwarding priority #13667
Conversation
@@ -103,7 +103,6 @@ class SpeedDialAction extends React.Component { | |||
placement={tooltipPlacement} | |||
onClose={this.handleTooltipClose} | |||
onOpen={this.handleTooltipOpen} | |||
className={classes.root} |
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 do the same thing for Button
though. Sure that is a little bit different since Button
has actual styles in root
. I would still vote to have a consistent API and use className={classNames(classes.root, classNameProp)}
to allow <EveryMuiComponent className="c1" classes={{ root: 'c2' }} />
which is perfectly valid for Button
and will be equivalent to <ButtonBase className="c1 c2" />
but for SpeedDialAction
this would only be <Tooltip className="c1" />
.
So I would always "suffer" the increased API surface if this increases API consistency.
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.
This change reverts a pull request I have merged too quickly without waiting for the visual regression tests. It was breaking the Speed Dial.
It's how I have discovered the Tooltip property priority issue.
For the SpeedDial, IMHO we should rename the button classes root. But I think that it's for another pull request. Here, I focus on the tooltip and going back to the previous state of affaire.
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.
but for SpeedDialAction this would only be .
It should be c1 c2
with the current implementation. The className isn't applied on the Tooltip. #13634
<h1 className="bar">H1</h1> | ||
</Tooltip>, | ||
); | ||
assert.strictEqual(wrapper.find('h1').props().className, 'bar'); |
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.
Has nothing to do with this PR but this is why forwarding/merging props with cloneElement
is always dangerous. At least by looking at it it might be obvious that foo
will be ignored but you could also argue that this warrants a special merge strategy for the props (i.e. concatenating classes). If the child props are opaque then this will be less obvious e.g. the child is another component without passed props that then renders the h1 with a different class and you're then debugging why foo
is not applied in the DOM.
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 agree, let's merge the class names. I believe it's what we do by "default" in the other components.
21737e3
to
3071343
Compare
The change is summarised by this test case: