Skip to content

Commit 7cce110

Browse files
committed
fix(ios): adjust homepage layout when virtual keyboard opens
- Reuse existing useVirtualKeyboard hook to track keyboard state - Dynamically set container height to 100dvh minus keyboardHeight - Input stays visible and centered when keyboard opens on iOS
1 parent dca9f8e commit 7cce110

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/webapp/src/components/pages/home/HomePage.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import TabLayout from '../TabLayout'
1313
import { useAuthStore, useStore } from '@stores'
1414
import { LuGithub, LuMessageCircle } from 'react-icons/lu'
1515
import { FaDiscord } from 'react-icons/fa'
16+
import useVirtualKeyboard from '@hooks/useVirtualKeyboard'
1617

1718
const SignInPanel = dynamic(() => import('@pages/panels/SignInPanel'), {
1819
loading: () => <Loading />
@@ -29,12 +30,16 @@ const HomePage = ({ hostname }: HomePageProps) => {
2930
const router = useRouter()
3031
const user = useAuthStore((state) => state.profile)
3132
const isAuthServiceAvailable = useStore((state) => state.settings.isAuthServiceAvailable)
33+
const keyboardHeight = useStore((state) => state.keyboardHeight)
3234

3335
const [documentName, setDocumentName] = useState('')
3436
const [isLoading, setIsLoading] = useState(false)
3537
const [isProfileOpen, setIsProfileOpen] = useState(false)
3638
const [isSignInOpen, setIsSignInOpen] = useState(false)
3739

40+
// Initialize keyboard tracking for iOS
41+
useVirtualKeyboard()
42+
3843
const navigateToDocument = (name?: string) => {
3944
setIsLoading(true)
4045
let docSlug = name || documentName
@@ -68,7 +73,9 @@ const HomePage = ({ hostname }: HomePageProps) => {
6873
<>
6974
<HeadSeo />
7075

71-
<div className="flex min-h-[100dvh] flex-col bg-gradient-to-b from-slate-50 to-slate-100">
76+
<div
77+
className="flex flex-col bg-gradient-to-b from-slate-50 to-slate-100"
78+
style={{ minHeight: keyboardHeight > 0 ? `calc(100dvh - ${keyboardHeight}px)` : '100dvh' }}>
7279
{/* Header */}
7380
<header className="flex shrink-0 items-center justify-between px-4 py-2 sm:px-6 sm:py-4">
7481
<div className="flex items-center gap-2">

0 commit comments

Comments
 (0)