react-select icon indicating copy to clipboard operation
react-select copied to clipboard

onMenuOpen triggers on each input

Open kino90 opened this issue 7 years ago • 7 comments

When a select (or creatable) is open, writing triggers onMenuOpen callback on each keystroke.

Demo: https://codesandbox.io/s/k0l8r2z6yr

I think that it should only trigger when opening the menu, right?

kino90 avatar Jan 09 '19 13:01 kino90

When a select (or creatable) is open, writing triggers onMenuOpen callback on each keystroke.

Demo: https://codesandbox.io/s/k0l8r2z6yr

I think that it should only trigger when opening the menu, right?

I confirm the bug with [email protected] in Chrome 72

ronjouch avatar Feb 19 '19 20:02 ronjouch

Any update on this?

Bryze avatar Feb 20 '19 08:02 Bryze

still on 3.0.4.

The Select component is calling parent props onMenuOpen. I imagine that's because the expected behaviour is that the menu should be always open if the user is typing. However, we could put a condition in the manger, or in the select, if the menu is already open, there's no reason to fire onMenuOpen again.

viniciusdacal avatar Jul 11 '19 21:07 viniciusdacal

Still the same behavior in 3.0.8

The onMenuOpen callback is triggered within handleInputChange in addition of being triggered already when the Menu actually opens in the openMenu method as is has been mentioned in https://github.com/JedWatson/react-select/issues/3620 as well

https://github.com/JedWatson/react-select/blob/3c7de0de52826fe74d303a01475c43fe88256156/packages/react-select/src/Select.js#L1092

https://github.com/JedWatson/react-select/blob/3c7de0de52826fe74d303a01475c43fe88256156/packages/react-select/src/Select.js#L502

lorisdev avatar Jan 07 '20 16:01 lorisdev

Well just removing the call to onMenuOpen inside handleInputChange breaks some tests ... Looks like the lib is relying on this buggy behaviour for a reason I don't have time to investigate ... Thus it may be a breaking change for many users and may require a major new version...

lorisdev avatar Jan 08 '20 09:01 lorisdev

pruik found that we should call onMenuOpen inside handleInputChange https://github.com/JedWatson/react-select/pull/3897#issuecomment-590781548

The PR now passes all the test 🎉 He proposed another PR as well which fixes this bug. We may see it fixed soon 🤞

lorisdev avatar Feb 26 '20 11:02 lorisdev

PR #3335 in review.

bladey avatar Jun 12 '20 02:06 bladey