Skip to content

Commit fbb62ff

Browse files
pdanpdanrstoenescu
authored andcommitted
fix(QSelect): Do the correct refocusing on $refs.target when closing options list (quasarframework#5309)
close quasarframework#5308
1 parent c1d1748 commit fbb62ff

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ui/dev/components/components/menu.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@
9292
</q-menu>
9393
</q-btn>
9494

95+
<q-btn color="primary" label="Menu with select">
96+
<q-menu cover @show="log('@show cover')" @hide="log('@hide cover')" content-class="q-pa-md">
97+
<div class="column q-gutter-md">
98+
<q-select v-model="selectModelS" :options="selectOptions" behavior="menu" filled label="Select single - menu" />
99+
<q-select v-model="selectModelM" :options="selectOptions" behavior="menu" filled multiple label="Select multiple - menu" />
100+
<q-select v-model="selectModelS" :options="selectOptions" behavior="dialog" filled label="Select single - dialog" />
101+
<q-select v-model="selectModelM" :options="selectOptions" behavior="dialog" filled multiple label="Select multiple - dialog" />
102+
</div>
103+
</q-menu>
104+
</q-btn>
105+
95106
<q-btn @click="dialog = true" label="Dialog" />
96107
<q-dialog v-model="dialog">
97108
<q-card class="q-pa-xl">
@@ -541,6 +552,10 @@ export default {
541552
max: 50,
542553
list,
543554
555+
selectModelS: null,
556+
selectModelM: null,
557+
selectOptions: list,
558+
544559
vIfTest: true,
545560
touchPosition: true,
546561
contextMenu: true,

ui/src/components/select/QSelect.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ export default Vue.extend({
10031003
return h(QDialog, {
10041004
props: {
10051005
value: this.dialog,
1006+
noRefocus: true,
10061007
position: this.useInput === true ? 'top' : void 0,
10071008
transitionShow: this.transitionShowComputed,
10081009
transitionHide: this.transitionHide
@@ -1041,7 +1042,14 @@ export default Vue.extend({
10411042
return
10421043
}
10431044

1044-
this.menu = false
1045+
if (this.menu === true) {
1046+
this.menu = false
1047+
1048+
// allow $refs.target to move to the field (when dialog)
1049+
this.$nextTick(() => {
1050+
this.$refs.target !== void 0 && this.$refs.target.focus()
1051+
})
1052+
}
10451053

10461054
if (this.focused === false) {
10471055
clearTimeout(this.filterId)

0 commit comments

Comments
 (0)