@@ -17,21 +17,17 @@ import { listChats } from "../../../api/chat";
1717import TestSection from "./TestSection" ;
1818
1919function HomePage ( ) {
20+ const [ viewportHeight , setViewportHeight ] = useState (
21+ window . visualViewport ?. height || window . innerHeight
22+ ) ;
2023 useEffect ( ( ) => {
21- const setViewportHeight = ( ) => {
22- const height = window . visualViewport ?. height || window . innerHeight ;
23- const vh = height * 0.01 ;
24- document . documentElement . style . setProperty ( "--vh" , `${ vh } px` ) ;
25- } ;
26-
27- setViewportHeight ( ) ;
28- window . visualViewport ?. addEventListener ( "resize" , setViewportHeight ) ;
29- window . addEventListener ( "resize" , setViewportHeight ) ;
30-
31- return ( ) => {
32- window . visualViewport ?. removeEventListener ( "resize" , setViewportHeight ) ;
33- window . removeEventListener ( "resize" , setViewportHeight ) ;
24+ const updateHeight = ( ) => {
25+ setViewportHeight ( window . visualViewport ?. height || window . innerHeight ) ;
3426 } ;
27+ updateHeight ( ) ;
28+ window . visualViewport ?. addEventListener ( "resize" , updateHeight ) ;
29+ return ( ) =>
30+ window . visualViewport ?. removeEventListener ( "resize" , updateHeight ) ;
3531 } , [ ] ) ;
3632
3733 const isKeyboardOpen = useKeyboardStore ( ( state ) => state . isKeyboardOpen ) ;
@@ -179,14 +175,18 @@ function HomePage() {
179175 return (
180176 < main
181177 className = "relative flex flex-col bg-white overflow-hidden"
182- style = { { height : "calc(var(--vh, 1vh) * 100)" } }
178+ style = { { height : ` ${ viewportHeight } px` } }
183179 >
184180 < div className = "sticky top-0 w-full gap-4 px-4 py-4" >
185181 < HeaderCard />
186182 </ div >
187183 < div
188- className = "flex-1 w-full overflow-y-auto overflow-x-hidden flex flex-col gap-4 px-4 py-4 mb-12"
189- style = { { WebkitOverflowScrolling : "touch" , overscrollBehavior : "none" } }
184+ className = "flex-1 w-full overflow-y-auto overflow-x-hidden flex flex-col gap-4 px-4 py-4"
185+ style = { {
186+ WebkitOverflowScrolling : "touch" ,
187+ overscrollBehavior : "none" ,
188+ marginBottom : isKeyboardOpen ? 0 : "3rem" ,
189+ } }
190190 >
191191 < DateChip date = { new Date ( ) } />
192192 { isNewSession && (
0 commit comments