Skip to content

Commit 54a6fa4

Browse files
committed
Auto-focus first item of license dropdown during filter
1 parent 96f7653 commit 54a6fa4

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/components/ScreenLicense.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
bg-color="white"
1818
label="license"
1919
clearable
20+
fill-input
21+
hide-selected
2022
input-debounce="0"
2123
outlined
2224
standout
@@ -47,6 +49,7 @@
4749
<script lang="ts">
4850
import { defineComponent, ref } from 'vue'
4951
import { useCff } from '../store/cff'
52+
import { QSelect } from 'quasar'
5053
import schema from '../schemas/1.2.0/schema.json'
5154
import Stepper from 'components/Stepper.vue'
5255
import StepperActions from 'components/StepperActions.vue'
@@ -67,17 +70,20 @@ export default defineComponent({
6770
licenses,
6871
options,
6972
setLicense,
70-
licenseFilterFunction (val: string, update: (a: unknown) => void) {
71-
if (val === '') {
72-
update(() => {
73-
options.value = licenses
74-
})
75-
return
76-
}
77-
73+
licenseFilterFunction (val: string, update: (a: unknown, b: unknown) => void) {
7874
update(() => {
79-
const needle = val.toLowerCase()
80-
options.value = licenses.filter(v => v.toLowerCase().indexOf(needle) > -1)
75+
if (val === '') {
76+
options.value = licenses
77+
} else {
78+
const needle = val.toLowerCase()
79+
options.value = licenses.filter(v => v.toLowerCase().indexOf(needle) > -1)
80+
}
81+
},
82+
(ref: QSelect) => {
83+
if (val !== '' && ref.options !== undefined && ref.options.length > 0) {
84+
ref.setOptionIndex(-1)
85+
ref.moveOptionSelection(1, true)
86+
}
8187
})
8288
}
8389
}

0 commit comments

Comments
 (0)