Skip to content

Commit da506d4

Browse files
committed
fix: handle shrink differently to reflect proper percentage sizes?
1 parent 59b3285 commit da506d4

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/components/splitter/splitter-pane.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,22 @@ export default class IgcSplitterPaneComponent extends LitElement {
4343
@query('[part~="base"]', true)
4444
private readonly _base!: HTMLElement;
4545

46+
private get _splitter(): IgcSplitterComponent | undefined {
47+
return this._splitterContext.value;
48+
}
49+
4650
private get _isPercentageSize() {
47-
return this._size === 'auto' || this._size.indexOf('%') !== -1;
51+
return this._size.indexOf('%') !== -1;
4852
}
4953

50-
private get _splitter(): IgcSplitterComponent | undefined {
51-
return this._splitterContext.value;
54+
private get _isAutoSize() {
55+
return this._size === 'auto';
5256
}
5357

5458
private get _flex() {
55-
const grow = this._isPercentageSize ? 1 : 0;
56-
return `${grow} ${grow} ${this._size}`;
59+
const grow = this._isAutoSize ? 1 : 0;
60+
const shrink = this._isAutoSize || this._isPercentageSize ? 1 : 0;
61+
return `${grow} ${shrink} ${this._size}`;
5762
}
5863

5964
private get _rectSize() {
@@ -188,8 +193,10 @@ export default class IgcSplitterPaneComponent extends LitElement {
188193
this._nextPane = panes[panes.indexOf(this) + 1];
189194

190195
// Store original size types before we start changing them
191-
this._isPrevPanePercentage = this._prevPane._isPercentageSize;
192-
this._isNextPanePercentage = this._nextPane._isPercentageSize;
196+
this._isPrevPanePercentage =
197+
this._prevPane._isPercentageSize || this._prevPane._isAutoSize;
198+
this._isNextPanePercentage =
199+
this._nextPane._isPercentageSize || this._nextPane._isAutoSize;
193200

194201
this._prevPaneInitialSize = this._rectSize;
195202
this._nextPaneInitialSize = this._nextPane._rectSize;
@@ -224,17 +231,22 @@ export default class IgcSplitterPaneComponent extends LitElement {
224231
(pane) => pane !== this && pane !== this._nextPane
225232
).forEach((pane) => {
226233
const size = pane._rectSize;
227-
this._adjustPaneSize(pane, pane._isPercentageSize, size, totalSize);
234+
this._adjustPaneSize(
235+
pane,
236+
pane._isPercentageSize || pane._isAutoSize,
237+
size,
238+
totalSize
239+
);
228240
});
229241
}
230242

231243
private _adjustPaneSize(
232244
pane: IgcSplitterPaneComponent,
233-
isPercent: boolean,
245+
isPercentOrAuto: boolean,
234246
size: number,
235247
totalSize: number
236248
) {
237-
if (isPercent) {
249+
if (isPercentOrAuto) {
238250
const percentPaneSize = (size / totalSize) * 100;
239251
pane.size = `${percentPaneSize}%`;
240252
} else {

0 commit comments

Comments
 (0)