From 4fa4c8d40b8f4f8e9812f388287ee2ecb969947c Mon Sep 17 00:00:00 2001 From: Jovines <1246634075@qq.com> Date: Wed, 14 Jan 2026 19:25:18 +0800 Subject: [PATCH] fix(mobile): add iOS keyboard home indicator safe area (#141) On iOS devices, when the keyboard is open, there's a home indicator bar (approximately 34px tall) at the bottom of the keyboard that needs additional safe area padding. Changes: - Add --oc-keyboard-home-indicator CSS variable - Add ios-keyboard-safe-area class for keyboard open state - Detect iOS userAgent and set keyboard home indicator height - Apply ios-keyboard-safe-area class to ChatInput when keyboard is open Co-authored-by: Jovines --- packages/ui/src/components/chat/ChatInput.tsx | 5 ++++- packages/ui/src/components/layout/MainLayout.tsx | 4 ++++ packages/ui/src/index.css | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/chat/ChatInput.tsx b/packages/ui/src/components/chat/ChatInput.tsx index 849046fb..c936c54f 100644 --- a/packages/ui/src/components/chat/ChatInput.tsx +++ b/packages/ui/src/components/chat/ChatInput.tsx @@ -1350,7 +1350,10 @@ export const ChatInput: React.FC = ({ onOpenSettings, scrollToBo
0 && !isKeyboardOpen ? { marginBottom: `${inputBarOffset}px` } : undefined} > diff --git a/packages/ui/src/components/layout/MainLayout.tsx b/packages/ui/src/components/layout/MainLayout.tsx index f4c6f6be..daa28eb3 100644 --- a/packages/ui/src/components/layout/MainLayout.tsx +++ b/packages/ui/src/components/layout/MainLayout.tsx @@ -201,6 +201,10 @@ export const MainLayout: React.FC = () => { root.style.setProperty('--oc-keyboard-inset', `${stickyKeyboardInset}px`); previousHeight = height; + const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent); + const keyboardHomeIndicator = isIOS && stickyKeyboardInset > 0 ? 34 : 0; + root.style.setProperty('--oc-keyboard-home-indicator', `${keyboardHomeIndicator}px`); + const avoidTarget = isTextTarget ? resolveKeyboardAvoidTarget(active) : null; if (!isMobile || !avoidTarget || !active) { diff --git a/packages/ui/src/index.css b/packages/ui/src/index.css index fc8d6f69..ac6db64f 100644 --- a/packages/ui/src/index.css +++ b/packages/ui/src/index.css @@ -13,6 +13,7 @@ --oc-visual-viewport-offset-top: 0px; --oc-keyboard-inset: 0px; --oc-keyboard-avoid-offset: 0px; + --oc-keyboard-home-indicator: 0px; --ui-regular-font-weight: 400; --oc-scrollbar-thumb: oklch(0.32 0.03 50 / 0.4); --oc-scrollbar-thumb-hover: oklch(0.32 0.03 50 / 0.6); @@ -1173,6 +1174,11 @@ html:not(.dark) .chat-scroll { padding-bottom: var(--oc-safe-area-bottom-visual) !important; } + /* iOS keyboard home indicator safe area - used when keyboard is open */ + .ios-keyboard-safe-area { + padding-bottom: calc(var(--oc-keyboard-home-indicator, 34px) + var(--oc-safe-area-bottom-visual, 0px)) !important; + } + /* Prevent keyboard-induced page scroll on iOS PWA */ body { min-height: 100vh;