-
Notifications
You must be signed in to change notification settings - Fork 79
fix(autocomplete): handle focusing when item is clicked and reset inputValue on form reset #11099
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
Conversation
// Autocomplete | ||
const autocomplete = document.getElementById("framework"); | ||
autocomplete.addEventListener("calciteAutocompleteChange", (event) => { | ||
autocomplete.inputValue = event.target.value; |
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.
This is for demonstration purposes only. We don't update the inputValue when a value has been selected. This is because we don't know what data would be best to put into the input. A value may be a unique id, a description or label may be better. Its best to leave this up to the end user to decide if they want to populate the input or not. In some cases, it may be best to leave the input as is with whatever the user has typed in so they can adjust their query.
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.
Nice!
…utValue on form reset (#11099) **Related Issue:** #10044 ## Summary - opens autocomplete when input is clicked - This is useful for when the input is already focused but the autocomplete is closed. - Sets focus and sets `open=false` when `autocomplete-item` is clicked - ensures that the input receives focus after an `autocomplete-item` is clicked - use `enterKeyHint` property JSX - update `onFormReset` to be called after form component logic - This allows us to reset the `inputValue` to the `defaultInputValue` without overriding existing logic - adds autocomplete to validation demo cc @benelan BEGIN_COMMIT_OVERRIDE END_COMMIT_OVERRIDE
Related Issue: #10044
Summary
open=false
whenautocomplete-item
is clickedautocomplete-item
is clickedenterKeyHint
property JSXonFormReset
to be called after form component logicinputValue
to thedefaultInputValue
without overriding existing logiccc @benelan
BEGIN_COMMIT_OVERRIDE
END_COMMIT_OVERRIDE