React-select: onMenuOpen triggers on each input

Created on 9 Jan 2019  路  7Comments  路  Source: JedWatson/react-select

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?

issubug-confirmed issuhas-pr issureviewed

Most helpful comment

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.

All 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?

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

Any update on this?

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.

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

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

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 馃

PR #3335 in review.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbonaci picture mbonaci  路  3Comments

AchinthaReemal picture AchinthaReemal  路  3Comments

geraldfullam picture geraldfullam  路  3Comments

pashap picture pashap  路  3Comments

sampatbadhe picture sampatbadhe  路  3Comments