-
-
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
[material-ui][IconButton] Fix disableRipple behaviour when disableRipple is set in MuiButtonBase theme #43714
Merged
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
679a841
Revert "[IconButton] Fix hover background color behavior (#43271)"
sai6855 7e677a4
add tests
sai6855 493d12c
fix test
sai6855 afb666b
fix diff
sai6855 5e5c258
fix diff
sai6855 0a00417
Update IconButton.test.js
sai6855 34eeaec
Apply fix to the colored buttons as well
DiegoAndai a82d288
Remove incorrect style rule
DiegoAndai d04a8d4
Add test for colored IconButton hover
DiegoAndai 02e1663
switch to CSS variable
siriwatknp 9ea0b19
Merge pull request #1 from siriwatknp/disable-ripple2
sai6855 1ef9fb0
Merge branch 'master' into disable-ripple
sai6855 96e0f14
Add experimental test
DiegoAndai eaca677
Merge branch 'master' into disable-ripple
DiegoAndai f843e03
Remove experimental test
DiegoAndai 4eaffa2
Remove hover tests
DiegoAndai 53eb100
Merge branch 'master' into disable-ripple
DiegoAndai fcb49fa
Remove unused import
DiegoAndai 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 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 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.
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.
@siriwatknp If I remember correctly, there's a problem with accessing color like this, isn't there? How might we implement this one?
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.
Ah, you are right. This won't work with Pigment CSS. Let me think of something else.
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.
Here is my proposal using CSS variable: sai6855#1.
We keep the previous logic and separate the
disableRipple
from the variants.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.
Sure, @DiegoAndai I'm not really familiar with the changes, but if you give the go-ahead to the sai6855#1 I can merge the PR.
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 @siriwatknp! This solution makes sense 👌🏼
@sai6855 may I ask you to update this PR with that solution?
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.
@Janpot I can confirm that your quick test works, as well as CSS variables in the IconButton component when running with Karma.
I discovered that the issue I'm facing, and why the test is not working, is that for some reason I can't get the hover style to be applied. I assume this is the reason the existing test is skipped in Karma: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/IconButton.test.js#L146
I've tried
fireEvent.mouseMove
,fireEvent.mouseOver
,fireEvent.mouseEnter
, anduserEvent.hover
, and none are working.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 don't think it's possible to trigger pseudo classes programmatically if that's what the style relies on on. So I don't believe
fireEvent
/userEvent
will ever be able to do that. testing-library/user-event#1210There 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 we are currently using
fireEvent
in JSDOM to test the hover style: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/IconButton.test.js#L152This is the only test we have that uses this, though, and it seems like:
😅
At this point, I'm considering removing the test and opening an issue to properly implement hover tests in the future. What do you think?
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're working on a migration to
vitest
and in their browser mode we'll have access to real user events https://vitest.dev/guide/browser/context.html. Doesn't look like karma has an equivalent. Maybe just skip the test for now?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.
👍🏼 agree