Skip to content

Commit e6e9f2c

Browse files
authored
fix(app-sidebar): mobile check [khcp-17790] (#2521)
Fix the mobile check for autoexpand of groups. Part of [KHCP-17790](https://konghq.atlassian.net/browse/KHCP-17790).
1 parent 6908c72 commit e6e9f2c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/core/app-layout/src/components/sidebar/AppSidebar.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ const topNavGroups = computed((): Map<string, SidebarPrimaryItem[]> => {
298298
return groups
299299
})
300300
301+
const isMobile = useMediaQuery(`max-width: ${KUI_BREAKPOINT_MOBILE}`)
301302
const getGroupConfig = (groupName: string = ''): GroupConfig | null => {
302303
if (groupName === UNGROUPED_NAME || !groupName.trim()) {
303304
return null
@@ -487,9 +488,9 @@ onMounted(async () => {
487488
window.addEventListener('resize', disableTransitions)
488489
489490
if (props.groupConfig) {
490-
for (const groupName in props.groupConfig) {
491-
// auto-expand all groups if the user is on mobile
492-
if (useMediaQuery(`(max-width: ${KUI_BREAKPOINT_MOBILE})`)) {
491+
// auto-expand all groups if the user is on mobile
492+
if (isMobile.value) {
493+
for (const groupName in props.groupConfig) {
493494
const group = props.groupConfig[groupName]
494495
group.collapsed = false
495496
}
@@ -506,6 +507,10 @@ onBeforeUnmount(() => {
506507
window.removeEventListener('resize', debouncedResizeHandler)
507508
window.removeEventListener('resize', disableTransitions)
508509
})
510+
511+
watch(() => props.groupConfig, (newConfig) => {
512+
console.log('groupConfig updated', newConfig)
513+
})
509514
</script>
510515

511516
<style lang="scss" scoped>

0 commit comments

Comments
 (0)