-
-
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
[Tabs] onChange fire even if value didn't change #22378
Comments
Thanks for the report. The underlying issue is that |
May I provide a PR? |
Sure, go for it. Don't forget to add a test. |
Sure |
Let me check for Contribution Guidelines |
Thanks olivier! |
@oliviertassinari @eps1lon I'm having trouble making the test pass (select variable is not getting value true) I run |
Maybe I have to let it elapse some time between clicks? |
@jjoselv The value is controlled in your test, it stays on 0, even after the first click. Click on the first item instead fireEvent.click(getAllByRole('tab')[1]);
expect(handleChange.callCount).to.equal(1);
expect(handleChange.args[0][1]).to.equal(1);
fireEvent.click(getAllByRole('tab')[0]);
expect(handleChange.callCount).to.equal(1); |
@oliviertassinari The thing is that I want to do the following test: Act -> Click on Tab 1 Act -> Click on Tab 1 (again) And that way the onChange handle does not run for already selected elements |
I see now, you code checks the same but in a different way. Ok, I'll submit your proposal 👍 |
Given option selectionFollowsFocus is true on Tabs component, when a Tab is clicked, onChange handler runs twice (one on focus and the other on clicked).
Current Behavior 😯
Given option selectionFollowsFocus is true on Tabs component, when a Tab is clicked, onChange handler runs twice (one on focus and the other on clicked).
Expected Behavior 🤔
It should only run once (check if already selected maybe).
Steps to Reproduce 🕹
Click on each Tab
https://codesandbox.io/s/friendly-sound-30c2y?file=/index.js
Steps:
The text was updated successfully, but these errors were encountered: