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 <jovines@qq.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jovines
parent
c4fb9d5730
commit
4fa4c8d40b
@@ -1350,7 +1350,10 @@ export const ChatInput: React.FC<ChatInputProps> = ({ onOpenSettings, scrollToBo
|
||||
|
||||
<form
|
||||
onSubmit={handleSubmit}
|
||||
className="pt-0 pb-2 md:pb-4 bottom-safe-area"
|
||||
className={cn(
|
||||
"pt-0 pb-2 md:pb-4",
|
||||
isMobile && isKeyboardOpen ? "ios-keyboard-safe-area" : "bottom-safe-area"
|
||||
)}
|
||||
data-keyboard-avoid="true"
|
||||
style={isMobile && inputBarOffset > 0 && !isKeyboardOpen ? { marginBottom: `${inputBarOffset}px` } : undefined}
|
||||
>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user