Skip to content

fix(VAutocomplete): use hidden select for native form submissions#22757

Open
faizkhairi wants to merge 1 commit intovuetifyjs:masterfrom
faizkhairi:fix/v-autocomplete-input-value-22270
Open

fix(VAutocomplete): use hidden select for native form submissions#22757
faizkhairi wants to merge 1 commit intovuetifyjs:masterfrom
faizkhairi:fix/v-autocomplete-input-value-22270

Conversation

@faizkhairi
Copy link
Copy Markdown

Description

Apply the same fix pattern from VSelect (#22330) to VAutocomplete. When using v-model or :model-value, the component's input value was empty until user interaction, breaking native form submission and Cypress tests.

Root Cause

VAutocomplete uses a real <input> for its search field, but the input's value is only populated when the component is focused (isFocused watcher sets search.value). This means native form submission always submits an empty string.

Fix

Mirror the VSelect fix from #22330:

  1. Import and call useAutocomplete(props) — reuses the existing composable created in fix(VSelect): Use hidden select for native form submissions #22330
  2. Pass name={undefined} to <VTextField> — excludes the visible text input from form submission
  3. Render a hidden <select> with <option> elements driven by items and selectedValues — this is what native form submission reads

Tests Added

  • Single selection: verifies FormData contains the selected value
  • Multiple selection: verifies FormData contains all selected values

Related

AI Disclosure

This contribution used AI assistance (Claude Code) for codebase exploration and implementation.

Apply the same fix pattern from VSelect (vuetifyjs#22330) to VAutocomplete.
The visible text input now passes name=undefined to avoid submitting
an empty string. A hidden <select> driven by the model carries the
actual selected value(s) through native form submission.

Fixes vuetifyjs#22270
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.10.7] VAutocomplete's input value

1 participant