Skip to content

Commit c7cff56

Browse files
committed
fix(MdSelect): fix regression in select model variable name
1 parent 5596575 commit c7cff56

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/components/MdField/MdSelect/MdOption.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
return this.$el.textContent.trim()
6262
}
6363
64-
return this.$slots.default[0].text.trim()
64+
const slot = this.$slots.default
65+
66+
return slot ? slot[0].text.trim() : ''
6567
},
6668
setIsSelected () {
6769
this.isSelected = this.inputLabel === this.getTextContent()

src/components/MdField/MdSelect/MdSelect.vue

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,36 @@
88
:md-offset-y="offset.y"
99
@md-opened="onOpen"
1010
@md-closed="onClose">
11-
<input
11+
<md-input
1212
class="md-input md-select-value"
1313
v-model="MdSelect.label"
14+
ref="input"
1415
readonly
1516
:disabled="disabled"
1617
:required="required"
1718
v-on="$listeners"
1819
@focus.prevent="onFocus"
20+
@blur.prevent="removeHighlight"
1921
@click="openSelect"
2022
@keydown.down="openSelect"
2123
@keydown.enter="openSelect"
2224
@keydown.space="openSelect" />
23-
<md-drop-down-icon ref="icon" @blur.native="removeHighlight" @click.native="openSelect" />
25+
<md-drop-down-icon @click.native="openSelect" />
2426

2527
<keep-alive>
26-
<md-menu-content ref="menu" class="md-select-menu" :md-content-class="mdClass" :md-list-class="mdDense && 'md-dense'" :style="menuStyles" :id="uniqueId">
28+
<md-menu-content
29+
ref="menu"
30+
class="md-select-menu"
31+
:md-content-class="mdClass"
32+
:md-list-class="mdDense && 'md-dense'"
33+
:style="menuStyles"
34+
:id="uniqueId">
2735
<slot />
2836
</md-menu-content>
2937
</keep-alive>
3038

31-
<md-input class="md-input-fake" v-model="content" :disabled="disabled" readonly />
32-
<select readonly v-model="content" v-bind="attributes"></select>
39+
<input class="md-input-fake" v-model="model" :disabled="disabled" readonly tabindex="-1" />
40+
<select readonly v-model="model" v-bind="attributes" tabindex="-1"></select>
3341
</md-menu>
3442
</template>
3543

@@ -88,7 +96,7 @@
8896
MdSelect.setContent = this.setContent
8997
MdSelect.setMultipleValue = this.setMultipleValue
9098
MdSelect.setMultipleContent = this.setMultipleContent
91-
MdSelect.modelValue = this.content
99+
MdSelect.modelValue = this.model
92100
93101
return { MdSelect }
94102
},
@@ -148,11 +156,10 @@
148156
applyHighlight () {
149157
this.MdField.focused = false
150158
this.MdField.highlighted = true
151-
this.$refs.icon.$el.focus()
159+
this.$refs.input.$el.focus()
152160
},
153161
onClose () {
154162
if (this.didMount) {
155-
this.$refs.icon.$el.setAttribute('tabindex', 1)
156163
this.applyHighlight()
157164
}
158165
},
@@ -163,7 +170,6 @@
163170
},
164171
removeHighlight () {
165172
this.MdField.highlighted = false
166-
this.$refs.icon.$el.removeAttribute('tabindex')
167173
},
168174
openSelect () {
169175
if (!this.disabled) {
@@ -180,7 +186,7 @@
180186
}
181187
},
182188
setValue (newValue) {
183-
this.content = newValue
189+
this.model = newValue
184190
this.setFieldValue()
185191
this.showSelect = false
186192
},
@@ -199,7 +205,7 @@
199205
setMultipleValue (value) {
200206
const newValue = value
201207
202-
this.toggleArrayValue(this.content, newValue)
208+
this.toggleArrayValue(this.model, newValue)
203209
this.setFieldValue()
204210
},
205211
setMultipleContentByValue () {

0 commit comments

Comments
 (0)