Skip to content

Commit c11333e

Browse files
committed
[FIX]: #1497 Page Layout Sider / padding issues
1 parent 3e96f79 commit c11333e

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

client/packages/lowcoder/src/comps/comps/containerComp/pageLayoutComp.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ export const PageLayoutComp = withMethodExposing(PageLayoutCompTmP, [
141141
params: [{ name: "collapsed", type: "boolean" }],
142142
},
143143
execute: (comp, values) => {
144-
const page = values[0] as number;
145-
if (page && page > 0) {
146-
// comp.children.pagination.children.pageNo.dispatchChangeValueAction(page);
147-
}
144+
const collapsed = !!values[0]; // Ensure boolean value
145+
comp.children.container.children.siderCollapsed.dispatchChangeValueAction(collapsed);
148146
},
149147
}
150148
]);

client/packages/lowcoder/src/comps/comps/pageLayoutComp/pageLayout.tsx

+20-7
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ const BodyInnerGrid = styled(InnerGrid)<{
103103
$bodyBackgroundImageSize: string;
104104
$bodyBackgroundImagePosition: string;
105105
$bodyBackgroundImageOrigin: string;
106+
$bodyPadding: string;
106107
}>`
107108
border-top: ${(props) => `${props.$showBorder ? props.$borderWidth : 0} solid ${props.$borderColor}`};
108109
flex: 1;
109110
border-radius: 0;
111+
padding: ${(props) => props.$bodyPadding || "0px"} !important;
110112
111113
${props => getBackgroundStyle({
112114
background: props.$backgroundColor,
@@ -169,9 +171,18 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
169171
const isMobile = checkIsMobile(maxWidth);
170172
const appRef = useRef();
171173

174+
// Handle mobile responsiveness for sider collapse
175+
useEffect(() => {
176+
// Force collapse on mobile if sider is shown
177+
if (isMobile && showSider) {
178+
props.setSiderCollapsed(true);
179+
}
180+
}, [isMobile, showSider, props.setSiderCollapsed]);
181+
172182
function onSiderCollapse (collapsed : boolean) {
173183
props.setSiderCollapsed(collapsed);
174-
// how to set the collapsed state in the container when the user manually collapses the sider?
184+
// We already updated the state through props.setSiderCollapsed
185+
// The parent component will update the value via useEffect
175186
}
176187

177188
useEffect(() => {setSiderCollapsed(container.siderCollapsed)} , [container.siderCollapsed]);
@@ -196,7 +207,7 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
196207
<Sider
197208
width={container.siderWidth}
198209
style={{ padding: "0px", margin: '0px', backgroundColor: siderStyle?.siderBackground || 'transparent' }}
199-
collapsible={container.siderCollapsible}
210+
collapsible={container.siderCollapsible && !isMobile}
200211
breakpoint="sm"
201212
collapsedWidth={container.siderCollapsedWidth}
202213
collapsed={siderCollapsed} onCollapse={(value) => onSiderCollapse(value)}
@@ -255,7 +266,7 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
255266
<Sider
256267
width={container.siderWidth}
257268
style={{ padding: "0px", margin: '0px', marginTop: style.borderWidth, backgroundColor: siderStyle?.siderBackground || 'transparent' }}
258-
collapsible={container.siderCollapsible}
269+
collapsible={container.siderCollapsible && !isMobile}
259270
breakpoint="sm"
260271
collapsedWidth={container.siderCollapsedWidth}
261272
collapsed={siderCollapsed} onCollapse={(value) => setSiderCollapsed(value)}
@@ -312,7 +323,8 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
312323
$bodyBackgroundImageOrigin={bodyStyle?.backgroundImageOrigin}
313324
$borderColor={style?.border}
314325
$borderWidth={style?.borderWidth}
315-
style={{ padding: bodyStyle.containerBodyPadding }} />
326+
$bodyPadding={bodyStyle.containerBodyPadding}
327+
style={{ padding: "0px" }} />
316328
)}
317329
</ScrollBar>
318330
</Content>
@@ -321,7 +333,7 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
321333
<Sider
322334
width={container.siderWidth}
323335
style={{ padding: "0px", margin: '0px', backgroundColor: siderStyle?.siderBackground || 'transparent' }}
324-
collapsible={container.siderCollapsible}
336+
collapsible={container.siderCollapsible && !isMobile}
325337
breakpoint="sm"
326338
collapsedWidth={container.siderCollapsedWidth}
327339
reverseArrow={true}
@@ -381,7 +393,8 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
381393
$bodyBackgroundImageOrigin={bodyStyle?.backgroundImageOrigin}
382394
$borderColor={style?.border}
383395
$borderWidth={style?.borderWidth}
384-
style={{ padding: bodyStyle.containerBodyPadding }} />
396+
$bodyPadding={bodyStyle.containerBodyPadding}
397+
style={{ padding: "0px" }} />
385398
)}
386399
</ScrollBar>
387400
</Content>
@@ -416,7 +429,7 @@ export function PageLayout(props: LayoutProps & { siderCollapsed: boolean; setSi
416429
<Sider
417430
width={container.siderWidth}
418431
style={{ padding: "0px", margin: '0px', backgroundColor: siderStyle?.siderBackground || 'transparent'}}
419-
collapsible={container.siderCollapsible}
432+
collapsible={container.siderCollapsible && !isMobile}
420433
breakpoint="sm"
421434
collapsedWidth={container.siderCollapsedWidth}
422435
reverseArrow={true}

0 commit comments

Comments
 (0)