Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/client/src/components/app/Layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
navTextColor,
logoHeight,
$context.device.width,
$context.device.height
$context.device.height,
collapsible
)
$: autoCloseSidePanel =
!$builderStore.inBuilder &&
Expand Down Expand Up @@ -204,7 +205,8 @@
textColor,
logoHeight,
width,
height
height,
isCollapsible = false
) => {
let style = `--width:${width}px; --height:${height}px;`
if (backgroundColor) {
Expand All @@ -213,7 +215,9 @@
if (textColor) {
style += `--navTextColor:${textColor};`
}
style += `--logoHeight:${logoHeight || 24}px;`
// Reduce logo height when collapsible to prevent navbar scrolling
const adjustedLogoHeight = isCollapsible ? Math.min(logoHeight || 24, 32) : (logoHeight || 24)
style += `--logoHeight:${adjustedLogoHeight}px;`
return style
}

Expand Down
33 changes: 33 additions & 0 deletions packages/client/src/components/app/NavItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
const dispatch = createEventDispatcher()

let renderKey
let previousCollapsedState = collapsed
let savedExpandedState = {}

$: isBuilderActive = testUrl => {
return (
Expand All @@ -35,6 +37,37 @@
$: caret = !renderLeftNav || expanded ? "caret-down" : "caret-right"
$: collapsedText = getShortText(text)

// Watch for navbar collapse state changes
$: if (collapsed !== previousCollapsedState) {
handleCollapsedStateChange(collapsed)
previousCollapsedState = collapsed
}

const handleCollapsedStateChange = isCollapsed => {
if (type === "sublinks" && subLinks?.length) {
if (isCollapsed) {
// Save the current expanded state before collapsing
if ($navStateStore[text]) {
savedExpandedState[text] = true
}
// Close all menus by updating the store
navStateStore.update(state => ({
...state,
[text]: false,
}))
} else {
// Restore the previous expanded state when expanding
if (savedExpandedState[text]) {
navStateStore.update(state => ({
...state,
[text]: true,
}))
delete savedExpandedState[text]
}
}
}
}

const getShortText = text => {
if (!text) {
return ""
Expand Down