fix(chat): scope keyboard avoidance to Facebook IAB

This commit is contained in:
2026-07-16 16:41:02 +08:00
parent aa801a3e18
commit 514297f469
4 changed files with 55 additions and 23 deletions
+8 -2
View File
@@ -1,5 +1,6 @@
export const CHAT_KEYBOARD_VISIBLE_THRESHOLD_PX = 80;
export const CHAT_KEYBOARD_ZOOM_THRESHOLD = 1.05;
export const CHAT_KEYBOARD_TARGET_GAP_PX = 8;
export const CHAT_KEYBOARD_FALLBACK_RATIO = 0.42;
export const CHAT_KEYBOARD_FALLBACK_MIN_PX = 260;
export const CHAT_KEYBOARD_FALLBACK_MAX_PX = 380;
@@ -67,7 +68,10 @@ export function resolveChatKeyboardInset(
return {
keyboardVisible: true,
bottomInset: Math.min(maxInset, Math.round(occludedHeight)),
bottomInset: Math.min(
maxInset,
Math.round(occludedHeight + CHAT_KEYBOARD_TARGET_GAP_PX),
),
source:
virtualKeyboardHeight >= visualViewportHeight
? "virtual-keyboard"
@@ -78,11 +82,13 @@ export function resolveChatKeyboardInset(
export function resolveChatKeyboardFallbackInset(
layoutHeight: number,
): number {
return Math.min(
const estimatedKeyboardHeight = Math.min(
CHAT_KEYBOARD_FALLBACK_MAX_PX,
Math.max(
CHAT_KEYBOARD_FALLBACK_MIN_PX,
Math.round(layoutHeight * CHAT_KEYBOARD_FALLBACK_RATIO),
),
);
return estimatedKeyboardHeight + CHAT_KEYBOARD_TARGET_GAP_PX;
}