When opening menu in `onFocus()`, clicking item does not close menu or trigger `onSelectedItemChange` weird check
-
downshiftversion:6.1.9 -
nodeversion:v14.18.0 -
npm(oryarn) version:6.14.15
This is a minimal codesandbox example of the issue:
https://codesandbox.io/s/pedantic-lumiere-u5j108?file=/src/index.js
What you did:
I added openMenu() to the onFocus() for the input in order to show the menu of options immediately.
What happened:
While the menu shows and selecting an item using the enter or tab key works, click on an item does not close the menu or update the controlled value.
If you uncomment lines 31-33, everything works as expected. I got this solution from a closed issue here : https://github.com/downshift-js/downshift/issues/1095#issuecomment-672266443 : however it seems like people are still commenting on the issue with different workarounds and I don't really understand why this extra check needs to be added to make clicking work even though the enter / tab keys work, it seems like there is a bug here.
Reproduction repository:
https://codesandbox.io/s/pedantic-lumiere-u5j108?file=/src/index.js
Problem description:
I believe all selection methods should work the same.
Suggested solution:
It seems like a bug that you have to add extra check (which to be honest, I am really not sure why it fixes this issue) to get one way of selecting to work when other ways don't need it.