@@ -66,6 +66,16 @@ function CollapsibleHeaderOnKeyboard({children, collapsibleHeaderOffset = 0}: Co
6666 if ( height <= 0 ) {
6767 return ;
6868 }
69+
70+ // Header re-measured in portrait mode and the content is taller than the previous measurement,
71+ // set the natural height to the new height and animate the height to the new height.
72+ // This can happen when header has different height on portrait and landscape mode.
73+ if ( ! isInLandscapeMode && height > naturalHeightRef . current && naturalHeightRef . current !== - 1 ) {
74+ naturalHeight . set ( height ) ;
75+ animatedHeight . set ( withTiming ( height , { duration : RESTORE_DURATION } ) ) ;
76+ return ;
77+ }
78+
6979 // First measurement, or content changed while header is fully open
7080 // (to skip onLayout calls triggered by our own height animation collapsing the view to 0)
7181 if ( naturalHeightRef . current === - 1 || animatedHeight . get ( ) >= naturalHeightRef . current ) {
@@ -81,7 +91,8 @@ function CollapsibleHeaderOnKeyboard({children, collapsibleHeaderOffset = 0}: Co
8191 if ( ! isInLandscapeMode && isFocused && naturalHeightValue !== - 1 ) {
8292 animatedHeight . set ( withTiming ( naturalHeightValue , { duration : RESTORE_DURATION } ) ) ;
8393 }
84- } , [ isInLandscapeMode , isFocused , animatedHeight ] ) ;
94+ // eslint-disable-next-line react-hooks/exhaustive-deps
95+ } , [ isInLandscapeMode ] ) ;
8596
8697 // Restores the header when the screen loses focus
8798 useEffect ( ( ) => {
@@ -159,7 +170,7 @@ function CollapsibleHeaderOnKeyboard({children, collapsibleHeaderOffset = 0}: Co
159170 // When fully open, leave height undefined so the view sizes itself naturally.
160171 // This avoids fighting the layout engine during orientation changes.
161172 if ( animatedHeight . get ( ) >= naturalHeight . get ( ) ) {
162- return { overflow : 'hidden' } ;
173+ return { overflow : 'hidden' , height : 'auto' } ;
163174 }
164175 return { height : animatedHeight . get ( ) , overflow : 'hidden' } ;
165176 } ) ;
0 commit comments