Skip to content

Commit 4ee8fc7

Browse files
authored
Fix incorrect contentContainerStyle size of new scrollable components (#869)
1 parent c18d8b9 commit 4ee8fc7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/core/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ export default function useSplitContentContainerStyles(
3737
contentContainerStyleNames
3838
);
3939

40-
// contentContainerStyle should always at least fill the parent to ensure sizing changes reflects properly on component and children
40+
const leftBorderWidth =
41+
flattenedStyle.borderLeftWidth ?? flattenedStyle.borderWidth ?? 0;
42+
const rightBorderWidth =
43+
flattenedStyle.borderRightWidth ?? flattenedStyle.borderWidth ?? 0;
44+
const topBorderWidth =
45+
flattenedStyle.borderTopWidth ?? flattenedStyle.borderWidth ?? 0;
46+
const bottomBorderWidth =
47+
flattenedStyle.borderBottomWidth ?? flattenedStyle.borderWidth ?? 0;
48+
49+
// contentContainerStyle should always at least fill the parent to ensure sizing changes reflects properly on component and children.
50+
// The measured sizes include borders, so we need to subtract those before applying
4151
if (measuredWidth) {
42-
contentContainerStyle.minWidth = measuredWidth;
52+
contentContainerStyle.minWidth =
53+
measuredWidth - leftBorderWidth - rightBorderWidth;
4354
}
4455
if (measuredHeight) {
45-
contentContainerStyle.minHeight = measuredHeight;
56+
contentContainerStyle.minHeight =
57+
measuredHeight - topBorderWidth - bottomBorderWidth;
4658
}
4759

4860
let style = omit(flattenedStyle, contentContainerStyleNames);

0 commit comments

Comments
 (0)