fix(VAutocomplete): populate input with selected item title on initial render#22954
Closed
sridhar-3009 wants to merge 1 commit into
Closed
fix(VAutocomplete): populate input with selected item title on initial render#22954sridhar-3009 wants to merge 1 commit into
sridhar-3009 wants to merge 1 commit into
Conversation
Contributor
|
Is it better than #22757? |
Contributor
Author
|
They solve different aspects of the same issue:
Both are complementary. If #22757 lands first, this PR's fix still addresses the visual "input is empty until focused" experience. That said, if the team prefers the hidden-select pattern as the canonical approach for VAutocomplete, happy to close this in favour of #22757. |
Contributor
|
closing in favor of #23022 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22270
Summary
VAutocompletedid not show the selected item's text in the input on initial render when a value was set viav-modelor:model-value. The input only became populated after the user first focused the component.Root cause
search(the text shown in the underlying input) was initialized to''and was only updated to reflect the selected item's title inside thewatch(isFocused)handler — which only fires on user interaction.VComboboxalready handles this correctly by initializing_searcheagerly from the model value and watchingmodelfor external changes.Fix
Added a
watch(model, ..., { immediate: true })inVAutocomplete.tsxthat mirrors theVComboboxpattern:Guards match the same conditions used in the focus watcher's focus-in branch:
!isFocused.value— avoids overwriting the user's live typing!props.multiple— multiple-select doesn't show a single title in the input!hasSelectionSlot.value— chips/custom selection slots render separately