-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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] Update autoSelect
prop description
#36280
Conversation
Netlify deploy previewhttps://deploy-preview-36280--material-ui.netlify.app/ Bundle size report |
* | ||
* Set to `true` if you want to save the value when input looses focus. | ||
* Set to `false` if you don't want to save the value when input looses focus. | ||
* @default false |
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.
kept default value as false to not break existing behaviour
@@ -935,7 +936,7 @@ export default function useAutocomplete(props) { | |||
|
|||
if (autoSelect && highlightedIndexRef.current !== -1 && popupOpen) { | |||
selectNewValue(event, filteredOptions[highlightedIndexRef.current], 'blur'); | |||
} else if (autoSelect && freeSolo && inputValue !== '') { | |||
} else if ((autoSelect || saveOnBlur) && freeSolo && 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.
@sai6855 This makes me think why not use autoSelect
?
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.
@siriwatknp In reality, using autoSelect
to save inputValue
on blur works, but description of autoSelect
in docs says, autoSelect
adds highlighted option to value. docs nowhere indicates autoSelect
adds inputValue
to value
. so maybe should we update docs instead of adding new prop?
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.
If we go in updation of autoSelect
prop description direction, it would be great if you can provide appropriate description, just to avoid further confusion
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.
From what I tested, adding a description sounds better than adding one more prop that likely does the same thing.
What do you think about this:
/**
* If `true`, the selected option becomes the value of the input
* when the Autocomplete loses focus unless the user chooses
* a different option or changes the character string in the input.
*
* In addition of `freeSolo` mode, the selected option will the input value
* if the Autocomplete loses focus without highlighing an option.
* @default false
*/
autoSelect?: boolean;
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.
- In addition of
freeSolo
mode, the selected option will the input value- if the Autocomplete loses focus without highlighing an option.
this part is bit unclear to me, if the Autocomplete loses focus **without** highlighing an option
then which option
will be the value of input as none of options are highlighted ?
should it be ?
* In addition of `freeSolo` mode, the typed value will be the input value
* if the Autocomplete loses focus without highlighing an option.
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.
Sounds 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.
@siriwatknp updated description
saveOnBlur
propautoSelect
prop description
autoSelect
prop descriptionautoSelect
prop description
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.
👍
@@ -66,6 +66,9 @@ export interface UseAutocompleteProps< | |||
* If `true`, the selected option becomes the value of the input | |||
* when the Autocomplete loses focus unless the user chooses | |||
* a different option or changes the character string in the input. | |||
* | |||
* In addition of `freeSolo` mode, the typed value will be the input 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.
I don't think I understand what this is saying. Is it meant to be "In addition to freeSolo mode", or "When using freeSolo mode"?
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.
i think when using freeSolo mode
sounds much better, as autocomplete saves typed value
only in freeSolo
mode
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.
ok that makes sense to me now, thanks!
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.
@samuelsycamore updated prop description in this commit 4e0edd0
closes #30521