Skip to content

Commit

Permalink
Auto-focus quick find input field
Browse files Browse the repository at this point in the history
  • Loading branch information
cld9x committed Jul 13, 2020
1 parent b3645eb commit cf07a93
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions ui/src/QuickFind.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<template>
<b-modal :active.sync="active"
<b-modal :active.sync="isActive"
:destroy-on-hide="false"
has-modal-card
trap-focus
aria-role="dialog"
aria-modal
can-cancel>
<b-field style="width:600px">
<b-autocomplete
ref="autocompleteInput"
:data="data"
placeholder="Find scene..."
field="query"
Expand Down Expand Up @@ -60,9 +62,15 @@
},
components: {VueLoadImage, GlobalEvents},
computed: {
active: {
isActive: {
get() {
return this.$store.state.overlay.showQuickFind;
const out = this.$store.state.overlay.showQuickFind;
if (out === true) {
this.$nextTick(() => {
this.$refs.autocompleteInput.$refs.input.focus();
});
}
return out;
},
set(values) {
this.$store.state.overlay.showQuickFind = values;
Expand All @@ -83,11 +91,17 @@
this.data = []
return
}
this.isFetching = true;
let resp = await ky.get(`/api/scene/search`, {
searchParams: {
q: query,
}
}).json();
this.isFetching = false;
if (resp.results > 0) {
this.data = resp.scenes;
} else {
Expand Down

0 comments on commit cf07a93

Please sign in to comment.