nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
22.12k stars 1.56k forks source link

[BUG] - Escape Key Deselects All Options in Select Component #4114

Open kimskovhusandersen opened 1 week ago

kimskovhusandersen commented 1 week ago

NextUI Version

2.4.8

Describe the bug

When the Escape key is pressed while the select dropdown is open, all selected options are deselected. This behavior is unexpected, as the Escape key should ideally close the dropdown without affecting the selections.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Open the select dropdown. Select one or more options (if multi-select). Press the Escape key while the dropdown is open.

Expected behavior

Pressing the Escape key should close the dropdown without changing the selected options.

Screenshots or Videos

https://github.com/user-attachments/assets/a898ea65-5998-4601-a75f-dd61d687dc2d

Operating System Version

macOS

Browser

Chrome

linear[bot] commented 1 week ago

ENG-1575 [BUG] - Escape Key Deselects All Options in Select Component

ryo-manba commented 6 days ago

It seems the same issue might exist in the single select as well.

abhinav700 commented 3 days ago

@wingkwong can I work on this issue?

abhinav700 commented 2 days ago

It looks like there are some other problems also. in the popover component of select, keyDown event's behavior works differently for different cases.

1) if a value is already selected -> only the keys other than enter and escape trigger a keyDown -> pressing escape resets the state without triggering keydown -> pressing enter on new value simply sets the new value. -> pressing enter on same value resets the select's value and does not trigger keydown

2) if no value is selected -> keys other than enter trigger the keyDown (even Escape key triggers it) -> pressing the enter sets a value.