From 2797e24a53314276020b411337e060fd624325b0 Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Tue, 26 Mar 2024 16:07:08 -0400 Subject: [PATCH] fix: split-panel now properly calculates it size when it goes from hidden to being shown. --- src/components/split-panel/split-panel.component.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/split-panel/split-panel.component.ts b/src/components/split-panel/split-panel.component.ts index 2154e772..66184e45 100644 --- a/src/components/split-panel/split-panel.component.ts +++ b/src/components/split-panel/split-panel.component.ts @@ -189,6 +189,14 @@ export default class SlSplitPanel extends ShoelaceElement { const { width, height } = entries[0].contentRect; this.size = this.vertical ? height : width; + // There's some weird logic that gets `this.cachedPositionInPixels = NaN` or `this.position === Infinity` when + // a split-panel goes from `display: none;` to showing. + if (isNaN(this.cachedPositionInPixels) || this.position === Infinity) { + this.cachedPositionInPixels = Number(this.getAttribute("position-in-pixels")) + this.positionInPixels = Number(this.getAttribute("position-in-pixels")) + this.position = this.pixelsToPercentage(this.positionInPixels); + } + // Resize when a primary panel is set if (this.primary) { this.position = this.pixelsToPercentage(this.cachedPositionInPixels);