-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Autocomplete] Fix keep listbox open on left/right keys when inputValue is not empty #31407
[Autocomplete] Fix keep listbox open on left/right keys when inputValue is not empty #31407
Conversation
@@ -474,6 +474,28 @@ describe('<Autocomplete />', () => { | |||
expect(textbox).toHaveFocus(); | |||
}); | |||
|
|||
it('should keep listbox open on pressing left or right keys when inputValue is not empty', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add test that will test that the listbox is closed if the input value is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure!
@@ -682,7 +682,9 @@ export default function useAutocomplete(props) { | |||
return; | |||
} | |||
|
|||
handleClose(event, 'toggleInput'); | |||
if (inputValue === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looks good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alisasanib for the contribution. Sorry it took me some time to get to it :)
Fixes: #31083
Code sandbox demo
Problem:
The list is closed upon clicking the ArrowLeft and ArrowRight key buttons if the user wants to move the cursor on the input value text.
Solution:
Adding a condition before closing the listbox, in order to check if the input value is not empty or not.