Skip to content

Commit

Permalink
fix(Splitter): isCollapsed not working on ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia authored Jan 20, 2025
1 parent 290ae29 commit 1f472e2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/radix-vue/src/Splitter/SplitterGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function collapsePanel(panelData: PanelData) {
assert(
panelSize != null,
`Panel size not found for panel "${panelData.id}"`,
`Panel size not found for panel "${panelData.id}"`,
)
if (panelSize !== collapsedSize) {
Expand Down Expand Up @@ -625,7 +625,7 @@ function getPanelSize(panelData: PanelData) {
assert(
panelSize != null,
`Panel size not found for panel "${panelData.id}"`,
`Panel size not found for panel "${panelData.id}"`,
)
return panelSize
Expand All @@ -640,7 +640,16 @@ function isPanelCollapsed(panelData: PanelData) {
panelSize,
} = panelDataHelper(panelDataArray, panelData, layout)
return collapsible === true && panelSize === collapsedSize
if (!collapsible)
return false
// panelSize is undefined during ssr due to vue ssr reactivity limitation.
if (panelSize === undefined) {
return panelData.constraints.defaultSize === panelData.constraints.collapsedSize
}
else {
return panelSize === collapsedSize
}
}
function isPanelExpanded(panelData: PanelData) {
Expand All @@ -654,7 +663,7 @@ function isPanelExpanded(panelData: PanelData) {
assert(
panelSize != null,
`Panel size not found for panel "${panelData.id}"`,
`Panel size not found for panel "${panelData.id}"`,
)
return !collapsible || panelSize > collapsedSize
Expand Down

0 comments on commit 1f472e2

Please sign in to comment.