onClear triggers onDeselect for all selected values
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
- Create a Select element with mode
multiple
, the flagallowClear
and multiple selectable options - Implement
onSelect
,onDeselect
andonClear
- Select multiple options
- Click on the clear button
What is expected?
The on clear button should only execute onClear
.
What is actually happening?
onClear
gets called first then for each selected value onDeselect
is called.
Environment | Info |
---|---|
antd | 4.18.3 |
React | 18.0.0-rc.0 |
System | Kubuntu 21.10 |
Browser | Chrome 96.0.4664.110 (Official Build) (64-bit) |
Expected behavior works for antd v4.17.3
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Select - Ant Design
Select component to select value from options. When To Use. A dropdown menu for displaying choices - an elegant alternative to the native...
Read more >Is it possible to prevent default onDeselect, (select input ...
1 Answer 1 ; value) => ; prevState => ; item => ; value) => ; prevState => ...
Read more >ReactJS UI Ant Design Select Component - GeeksforGeeks
Select Component is used to select a value from options. ... onClear: It is a called function that is triggered when the option...
Read more >JQueryTextboxList < System < PDLWiki
Instead of specifying callbacks using the onSelect or onDeselect options, custom events are ... SelectValue, value, triggered when a value is selected.
Read more >Select - Ant Design
Select component to select value from options. When To Use#. A dropdown menu for displaying choices - an elegant alternative to the native...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello,
Same problem here. Since v4.18.0, onDeselect is called when onClear is triggered.
If this is wanted it should be considered a breaking change and documented. It’s a huge difference when you override these functions.
But for me, it’s a bug. onClear should not call onDeselect. If someone wants to trigger something for onClear AND onDeselect it’s easy to do it in both function. But now that onClear trigger onDeselect you cannot prevent both function to be executed. It should be reverted or at least a param should be given to onDeselect, so it’s possible to know when to change the behavior because it’s onClear.
Btw, the library I created now have a bug because of this: https://github.com/xrutayisire/react-js-cron/issues/18 😢
I hope this can be fixed soon 😃
Happy to help if needed!
Are there any updates on when it will be merged?