Focus task detail elements when they show up

This commit is contained in:
kolaente 2021-04-18 16:50:12 +02:00
parent af4b1aba70
commit 747a9fe505
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 35 additions and 21 deletions

View file

@ -3,6 +3,8 @@
class="multiselect" class="multiselect"
:class="{'has-search-results': searchResultsVisible}" :class="{'has-search-results': searchResultsVisible}"
ref="multiselectRoot" ref="multiselectRoot"
tabindex="-1"
@focus="focus"
> >
<div class="control" :class="{'is-loading': loading || localLoading}"> <div class="control" :class="{'is-loading': loading || localLoading}">
<div class="input-wrapper input" :class="{'has-multiple': multiple && Array.isArray(internalValue) && internalValue.length > 0}"> <div class="input-wrapper input" :class="{'has-multiple': multiple && Array.isArray(internalValue) && internalValue.length > 0}">
@ -324,6 +326,9 @@ export default {
this.$emit('input', this.internalValue) this.$emit('input', this.internalValue)
this.$emit('remove', item) this.$emit('remove', item)
}, },
focus() {
this.$refs.searchInput.focus()
},
}, },
} }
</script> </script>

View file

@ -1,4 +1,8 @@
<template> <template>
<div
tabindex="-1"
@focus="focus"
>
<multiselect <multiselect
:loading="listUserService.loading" :loading="listUserService.loading"
placeholder="Type to assign a user..." placeholder="Type to assign a user..."
@ -10,6 +14,7 @@
label="username" label="username"
select-placeholder="Assign this user" select-placeholder="Assign this user"
v-model="assignees" v-model="assignees"
ref="multiselect"
> >
<template v-slot:tag="props"> <template v-slot:tag="props">
<span class="assignee"> <span class="assignee">
@ -20,6 +25,7 @@
</span> </span>
</template> </template>
</multiselect> </multiselect>
</div>
</template> </template>
<script> <script>
@ -119,6 +125,9 @@ export default {
clearAllFoundUsers() { clearAllFoundUsers() {
this.$set(this, 'foundUsers', []) this.$set(this, 'foundUsers', [])
}, },
focus() {
this.$refs.multiselect.focus()
},
}, },
} }
</script> </script>