Skip to content

Commit

Permalink
added ref to mhr search header (#2016)
Browse files Browse the repository at this point in the history
  • Loading branch information
flutistar authored Sep 4, 2024
1 parent 09b967b commit a4a1f2c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ppr-ui/src/components/search/SearchBarList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<v-list-item
class="py-2"
:class="{ 'top-border' : item.raw.icon === 'mdi-home' }"
ref="mhrSearchHeaderRef"
@click="toggleGroup(item.raw.group)"
>
<v-row
Expand Down Expand Up @@ -68,7 +69,7 @@
</v-select>
</template>
<script lang="ts">
import { computed, defineComponent, reactive, ref, toRefs } from 'vue'
import { computed, defineComponent, reactive, ref, toRefs, nextTick } from 'vue'
import { useStore } from '@/store/store'
import { MHRSearchTypes, SearchTypes } from '@/resources'
import { APISearchTypes, UISearchTypes } from '@/enums'
Expand Down Expand Up @@ -97,6 +98,7 @@ export default defineComponent({
hasMhrEnabled
} = storeToRefs(useStore())
const searchSelect = ref(null)
const mhrSearchHeaderRef = ref(null)
const localState = reactive({
searchTypes: UISearchTypes,
searchTypeValues: APISearchTypes,
Expand Down Expand Up @@ -169,7 +171,7 @@ export default defineComponent({
showMenu: false
})
const toggleGroup = (group: number) => {
const toggleGroup = async (group: number) => {
const initial = localState.displayGroup[group]
// collapse both groups as only one group can be expanded at once
localState.displayGroup = {
Expand All @@ -179,6 +181,11 @@ export default defineComponent({
// expand desired group
localState.displayGroup[group] = !initial
localState.displayItems = [...localState.origItems]
await nextTick();
if(group === 2) {
mhrSearchHeaderRef.value?.$el?.focus()
}
}
const selectSearchType = (val: SearchTypeIF) => {
emit('selected', val)
Expand All @@ -195,6 +202,7 @@ export default defineComponent({
return {
updateSelections,
searchSelect,
mhrSearchHeaderRef,
selectSearchType,
toggleGroup,
...toRefs(localState)
Expand Down

0 comments on commit a4a1f2c

Please sign in to comment.