@@ -10,6 +10,7 @@ export interface UseWindowHeightFillProps {
10
10
serverVhFallback ?: number ;
11
11
includeMobile ?: boolean ;
12
12
observeDomChanges ?: boolean ;
13
+ maxHeight ?: number ;
13
14
containerRef : RefObject < HTMLDivElement > ;
14
15
observedElementRef ?: RefObject < HTMLDivElement > ;
15
16
}
@@ -20,6 +21,7 @@ export const useWindowHeightFill = ({
20
21
serverVhFallback = 100 ,
21
22
containerRef,
22
23
observedElementRef,
24
+ maxHeight,
23
25
} : UseWindowHeightFillProps ) : string => {
24
26
// Create an observer instance linked to the callback function
25
27
const cappedHeight = useResponsiveValue ( [ includeMobile , , true ] ) ;
@@ -39,10 +41,12 @@ export const useWindowHeightFill = ({
39
41
themeClass ,
40
42
themeContractVars . space [ bottomGap ] ,
41
43
) || '0px' ;
42
- const availableHeight =
44
+ const availableHeight = Math . min (
45
+ maxHeight ?? Number . POSITIVE_INFINITY ,
43
46
window . innerHeight -
44
- // @ts -ignore
45
- containerRef . current . getBoundingClientRect ( ) . top ;
47
+ // @ts -ignore
48
+ containerRef . current . getBoundingClientRect ( ) . top ,
49
+ ) ;
46
50
const newHeight = gap
47
51
? `calc(${ availableHeight } px - ${ gap } )`
48
52
: `${ availableHeight } px` ;
@@ -79,6 +83,7 @@ export const useWindowHeightFill = ({
79
83
document ?. body ,
80
84
themeClass ,
81
85
bottomGap ,
86
+ maxHeight ,
82
87
] ) ;
83
88
84
89
return cappedHeight ? containerHeight : 'auto' ;
0 commit comments