Skip to content

Commit

Permalink
filter group accordion open if present in route.query
Browse files Browse the repository at this point in the history
  • Loading branch information
stephiescastle committed Sep 15, 2024
1 parent 71e3715 commit fafac8b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<SearchFilterGroupAccordionItem
v-if="hasSubFilters(bucket.key_as_string || bucket.key)"
class="w-auto"
:init-open="subFilterIsInQueryParams(bucket.key_as_string || bucket.key)"
>
<template #header>
<!-- correct for zero based index -->
Expand Down Expand Up @@ -175,6 +176,10 @@ export default {
subFilters: {
type: Object as PropType<SubFiltersObject>,
default: undefined
},
subFilterAggKey: {
type: String,
default: undefined
}
},
emits: ['update:filterBy'],
Expand Down Expand Up @@ -268,6 +273,20 @@ export default {
}
return undefined
},
subFilterIsInQueryParams(bucketKey) {
const subFilters = this.getSubFilters(bucketKey)
let state = false
if (subFilters?.length) {
subFilters.forEach((subFilter) => {
const agg = subFilter.agg
const key = subFilter.key
if (agg && key && this.$route.query[agg]?.includes(key)) {
state = true
}
})
}
return state
},
getSubFilters(filterKey) {
const lookupKey = this.getSubFilterParentKey(filterKey)
// check if any of the keys are populated in subFilters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, reactive, ref } from 'vue'
import { uniqueId } from 'lodash'
import IconPlus from './../Icons/IconPlus.vue'
export interface SearchFilterGroupAccordionItemProps {
initOpen?: boolean
}
// define props
const props = withDefaults(defineProps<SearchFilterGroupAccordionItemProps>(), {
initOpen: false
})
const { initOpen } = reactive(props)
const ariaExpanded = ref(false)
const isHidden = ref(true)
const isHidden = ref(!initOpen)
const itemId = ref(uniqueId())
const panelId = computed(() => {
Expand Down

0 comments on commit fafac8b

Please sign in to comment.