@@ -71,13 +71,16 @@ export const ResizePanels: React.FC<ResizePanelsProps> = ({
7171 const effectiveHeight = height ?? 0 ;
7272 const fraction = FRACTIONS [ main ] ;
7373 const [ isResizing , setIsResizing ] = useState ( true ) ;
74- const [ containerHeight , setContainerHeight ] = useState ( 0 ) ;
74+ const [ containerHeight , setContainerHeight ] = useState < number | undefined > (
75+ undefined ,
76+ ) ;
7577 const containerRef = useRef < Resizable > ( null ) ;
7678 const upperSearchRef = useRef < HTMLInputElement > ( null ) ;
7779 const lowerSearchRef = useRef < HTMLInputElement > ( null ) ;
7880
7981 const isLowerCollapsed = effectiveHeight <= HEADER_HEIGHT ;
8082 const isUpperCollapsed =
83+ containerHeight !== undefined &&
8184 effectiveHeight >= containerHeight - HEADER_HEIGHT - 1 ;
8285
8386 useLayoutEffect ( ( ) => {
@@ -88,16 +91,15 @@ export const ResizePanels: React.FC<ResizePanelsProps> = ({
8891
8992 useEffect ( ( ) => {
9093 const applyGoldenRatio = ( ) =>
91- containerRef . current &&
92- setHeight ( containerRef . current . size . height / fraction ) ;
94+ containerHeight !== undefined && setHeight ( containerHeight / fraction ) ;
9395
9496 heightIsNull && applyGoldenRatio ( ) ;
9597 window . addEventListener ( 'resize' , applyGoldenRatio ) ;
9698
9799 return ( ) => {
98100 window . removeEventListener ( 'resize' , applyGoldenRatio ) ;
99101 } ;
100- } , [ fraction , heightIsNull , setHeight ] ) ;
102+ } , [ fraction , heightIsNull , setHeight , containerHeight ] ) ;
101103
102104 useIpcRenderer (
103105 upperPanel . search . channel ,
@@ -260,10 +262,10 @@ export const ResizePanels: React.FC<ResizePanelsProps> = ({
260262 disabled = { isLowerCollapsed }
261263 onClick = { ( ) => {
262264 setIsResizing ( true ) ;
263- if ( containerRef . current ) {
264- effectiveHeight <= containerRef . current . size . height / fraction
265+ if ( containerHeight !== undefined ) {
266+ effectiveHeight <= containerHeight / fraction
265267 ? setHeight ( HEADER_HEIGHT )
266- : setHeight ( containerRef . current . size . height / fraction ) ;
268+ : setHeight ( containerHeight / fraction ) ;
267269 }
268270 setIsResizing ( false ) ;
269271 } }
@@ -278,10 +280,10 @@ export const ResizePanels: React.FC<ResizePanelsProps> = ({
278280 disabled = { isUpperCollapsed }
279281 onClick = { ( ) => {
280282 setIsResizing ( true ) ;
281- if ( containerRef . current ) {
282- effectiveHeight < containerRef . current . size . height / fraction
283- ? setHeight ( containerRef . current . size . height / fraction )
284- : setHeight ( containerRef . current . size . height - HEADER_HEIGHT ) ;
283+ if ( containerHeight !== undefined ) {
284+ effectiveHeight < containerHeight / fraction
285+ ? setHeight ( containerHeight / fraction )
286+ : setHeight ( containerHeight - HEADER_HEIGHT ) ;
285287 }
286288 setIsResizing ( false ) ;
287289 } }
0 commit comments