-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
[Checkbox, Menu, and Radio] Fix: Update keepMounted Prop Logic for Inline Elements #1329
base: master
Are you sure you want to change the base?
Changes from 7 commits
c09a5d9
cd2a8dd
2fdd28f
2fa4c1c
df77283
cfbb532
d31dcd8
2848aac
e952ad1
0cb08ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,45 +19,6 @@ describe('<Radio.Indicator />', () => { | |
}, | ||
})); | ||
|
||
it('should remove the indicator when there is no exit animation defined', async ({ skip }) => { | ||
if (isJSDOM) { | ||
skip(); | ||
} | ||
|
||
function Test() { | ||
const [value, setValue] = React.useState('a'); | ||
return ( | ||
<div> | ||
<button onClick={() => setValue('b')}>Close</button> | ||
<RadioGroup value={value}> | ||
<Radio.Root value="a"> | ||
<Radio.Indicator | ||
className="animation-test-indicator" | ||
keepMounted | ||
data-testid="indicator-a" | ||
/> | ||
Comment on lines
-34
to
-38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atomiks while reverting the test cases removal commit, I have found that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for spotting - that's unintended. All indicators should unmount by default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atomiks I set it to false by default, like other indicator components. I also reverted the test cases you suggested earlier. Instead of checking for hidden props, I now check if the indicator element exists. Please check the latest commit and let me know if any modifications are needed. |
||
</Radio.Root> | ||
<Radio.Root value="a"> | ||
<Radio.Indicator className="animation-test-indicator" keepMounted /> | ||
</Radio.Root> | ||
</RadioGroup> | ||
</div> | ||
); | ||
} | ||
|
||
const { user } = await render(<Test />); | ||
|
||
expect(screen.getByTestId('indicator-a')).not.to.have.attribute('hidden'); | ||
|
||
const closeButton = screen.getByText('Close'); | ||
|
||
await user.click(closeButton); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId('indicator-a')).to.have.attribute('hidden'); | ||
}); | ||
}); | ||
|
||
it('should remove the indicator when the animation finishes', async ({ skip }) => { | ||
if (isJSDOM) { | ||
skip(); | ||
|
@@ -109,15 +70,11 @@ describe('<Radio.Indicator />', () => { | |
|
||
const { user } = await render(<Test />); | ||
|
||
expect(screen.getByTestId('indicator-a')).not.to.have.attribute('hidden'); | ||
|
||
const closeButton = screen.getByText('Close'); | ||
await user.click(closeButton); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId('indicator-a')).to.have.attribute('hidden'); | ||
expect(animationFinished).to.equal(true); | ||
}); | ||
|
||
expect(animationFinished).to.equal(true); | ||
}); | ||
}); |
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 think each of these tests can be kept, just check for
null
instead ofhidden
(removing thekeepMounted
prop in the test)?