-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Closed
Closed
Copy link
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.🐞 bugSomething isn't workingSomething isn't workinghas workaroundA workaround has been found to avoid the problemA workaround has been found to avoid the problemscope: ssr
Description
Version
3.2.29
Reproduction link
Steps to reproduce
Create a template with <select v-model="...">
and some <option :value="...">
elements. And then look at the rendered HTML. There will never be a selected
attribute on the option
elements.
When loading the SSR rendered page with disabled JavaScript it will always select the first option, because no option
in the HTML is actually selected
.
What is expected?
Similar behavior to <input v-model="...">
. For input
elements this will insert a value="..."
attribute.
Though <select v-model="...">
should insert a selected
attribute for the selected option element. (Or elements when using <select multiple>
).
What is actually happening?
No selected
attribute is added to the SSR rendered HTML.
A workaround is to set :selected
manually:
<select v-model="selected">
<option disabled value="">Please select one</option>
<option value="A" :selected="selected === 'A'">A</option>
<option value="B" :selected="selected === 'B'">B</option>
<option value="C" :selected="selected === 'C'">C</option>
</select>
pascalbaljet, danbrellis and MohannadNaj
Metadata
Metadata
Assignees
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.🐞 bugSomething isn't workingSomething isn't workinghas workaroundA workaround has been found to avoid the problemA workaround has been found to avoid the problemscope: ssr