@@ -27,6 +27,7 @@ import { getBackgroundStyle } from "@lowcoder-ee/util/styleUtils";
2727const UICompContainer = styled . div < {
2828 $maxWidth ?: number ;
2929 $rowCount ?: number ;
30+ $fillHeight ?: boolean ;
3031 readOnly ?: boolean ;
3132 $bgColor : string ;
3233 $bgImage ?: string ;
@@ -35,8 +36,8 @@ const UICompContainer = styled.div<{
3536 $bgImageOrigin ?: string ;
3637 $bgImagePosition ?: string ;
3738} > `
38- height: auto;
39- min-height: ${ props => props . $rowCount === Infinity ? '100%' : 'auto' } ;
39+ height: ${ props => props . $fillHeight ? '100%' : ' auto' } ;
40+ min-height: ${ props => props . $fillHeight ? '0' : props . $ rowCount === Infinity ? '100%' : 'auto' } ;
4041 margin: 0 auto;
4142 max-width: ${ ( props ) => props . $maxWidth || 1600 } px;
4243
@@ -68,6 +69,18 @@ const gridLayoutCanvasProps = {
6869 isCanvas : true ,
6970} ;
7071
72+ export function shouldShowStretchCanvasHeight ( rowCount : number ) {
73+ return rowCount !== DEFAULT_ROW_COUNT ;
74+ }
75+
76+ export function shouldStretchCanvasHeight (
77+ rowCount : number ,
78+ readOnly : boolean ,
79+ gridStretchHeight ?: boolean
80+ ) {
81+ return readOnly && Boolean ( gridStretchHeight ) && rowCount !== DEFAULT_ROW_COUNT ;
82+ }
83+
7184function getDragSelectedNames (
7285 items : GridItemsType ,
7386 layout : GridLayoutType ,
@@ -176,7 +189,7 @@ export const CanvasView = React.memo((props: ContainerBaseProps) => {
176189
177190 const externalState = useContext ( ExternalEditorContext ) ;
178191 const {
179- readOnly,
192+ readOnly = false ,
180193 appType,
181194 rootContainerExtraHeight = DEFAULT_EXTRA_HEIGHT ,
182195 rootContainerPadding,
@@ -271,6 +284,10 @@ export const CanvasView = React.memo((props: ContainerBaseProps) => {
271284 || defaultTheme ?. gridRowCount
272285 || DEFAULT_ROW_COUNT ;
273286 } , [ preventStylesOverwriting , appSettings , currentTheme , defaultTheme ] ) ;
287+ const isStretchCanvasHeight = useMemo (
288+ ( ) => shouldStretchCanvasHeight ( defaultRowCount ?? DEFAULT_ROW_COUNT , readOnly , ( appSettings as any ) . gridStretchHeight ) ,
289+ [ appSettings , defaultRowCount , readOnly ]
290+ ) ;
274291
275292 const defaultContainerPadding : [ number , number ] = useMemo ( ( ) => {
276293 const DEFAULT_PADDING = isMobile ? DEFAULT_MOBILE_PADDING : DEFAULT_CONTAINER_PADDING ;
@@ -305,10 +322,11 @@ export const CanvasView = React.memo((props: ContainerBaseProps) => {
305322
306323 if ( readOnly ) {
307324 return (
308- < UICompContainer
309- $maxWidth = { maxWidth }
310- $rowCount = { defaultRowCount }
311- readOnly = { true }
325+ < UICompContainer
326+ $maxWidth = { maxWidth }
327+ $rowCount = { defaultRowCount }
328+ $fillHeight = { isStretchCanvasHeight }
329+ readOnly = { true }
312330 className = { CNRootContainer }
313331 $bgColor = { bgColor }
314332 $bgImage = { bgImage }
@@ -324,6 +342,9 @@ export const CanvasView = React.memo((props: ContainerBaseProps) => {
324342 { ...props }
325343 positionParams = { positionParams }
326344 { ...gridLayoutCanvasProps }
345+ autoHeight = { ! isStretchCanvasHeight }
346+ rowCount = { defaultRowCount }
347+ isRowCountLocked = { isStretchCanvasHeight }
327348 bgColor = { bgColor }
328349 radius = "0px"
329350 emptyRows = { defaultRowCount }
@@ -341,6 +362,7 @@ export const CanvasView = React.memo((props: ContainerBaseProps) => {
341362 < UICompContainer
342363 $maxWidth = { maxWidth }
343364 $rowCount = { defaultRowCount }
365+ $fillHeight = { isStretchCanvasHeight }
344366 className = { CNRootContainer }
345367 $bgColor = { bgColor }
346368 $bgImage = { bgImage }
@@ -360,6 +382,9 @@ export const CanvasView = React.memo((props: ContainerBaseProps) => {
360382 overflow = { rootContainerOverflow }
361383 { ...props }
362384 { ...gridLayoutCanvasProps }
385+ autoHeight = { ! isStretchCanvasHeight }
386+ rowCount = { defaultRowCount }
387+ isRowCountLocked = { isStretchCanvasHeight }
363388 dragSelectedComps = { dragSelectedComps }
364389 scrollContainerRef = { scrollContainerRef }
365390 isDroppable = { ! isModule }
0 commit comments