question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

Edit on CodeSandbox

Steps to reproduce

  1. Create a Select element with mode multiple, the flag allowClear and multiple selectable options
  2. Implement onSelect, onDeselect and onClear
  3. Select multiple options
  4. 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:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
xrutayisirecommented, Feb 13, 2022

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!

2reactions
Kn3chtcommented, Sep 21, 2022

Are there any updates on when it will be merged?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found