|
|
|
@ -94,13 +94,10 @@ function setLift(nextLift: number) { |
|
|
|
function getKeyboardTop() { |
|
|
|
if (!keyboardVisible || !activeQuestionInput) return null; |
|
|
|
|
|
|
|
// When keyboard is opening/visible, use the projected full keyboard height
|
|
|
|
// (either current incoming height or last known full keyboard height)
|
|
|
|
// so the CSS transition animates in ONE single smooth, continuous curve concurrent with OS keyboard.
|
|
|
|
const targetHeight = Math.max( |
|
|
|
keyboardHeight, |
|
|
|
lastKeyboardHeight > 200 ? lastKeyboardHeight : 320, |
|
|
|
); |
|
|
|
// Expected full keyboard height for mobile devices is ~330px
|
|
|
|
const fullKeyboardHeight = |
|
|
|
lastKeyboardHeight > 250 ? lastKeyboardHeight : 330; |
|
|
|
const targetHeight = Math.max(keyboardHeight, fullKeyboardHeight); |
|
|
|
|
|
|
|
const flutterTop = window.innerHeight - targetHeight; |
|
|
|
const viewport = window.visualViewport; |
|
|
|
@ -183,7 +180,9 @@ export function updateQuestionKeyboardHeight(height: number) { |
|
|
|
keyboardHeight = nextHeight; |
|
|
|
keyboardVisible = keyboardHeight > KEYBOARD_THRESHOLD; |
|
|
|
if (keyboardVisible) { |
|
|
|
lastKeyboardHeight = keyboardHeight; |
|
|
|
if (nextHeight > 250) { |
|
|
|
lastKeyboardHeight = Math.max(lastKeyboardHeight, nextHeight); |
|
|
|
} |
|
|
|
if (isActiveQuestionKeyboardInput(document.activeElement)) { |
|
|
|
activeQuestionInput = document.activeElement; |
|
|
|
} |
|
|
|
@ -208,10 +207,9 @@ export function resetQuestionKeyboardState() { |
|
|
|
if (isActiveQuestionKeyboardInput(document.activeElement)) { |
|
|
|
document.activeElement.blur(); |
|
|
|
} |
|
|
|
activeQuestionInput = null; |
|
|
|
keyboardVisible = false; |
|
|
|
keyboardHeight = 0; |
|
|
|
compactSheetTop = null; |
|
|
|
activeQuestionInput = null; |
|
|
|
setLift(0); |
|
|
|
} |
|
|
|
|
|
|
|
@ -222,11 +220,11 @@ export function useQuestionViewportCoordinator() { |
|
|
|
const handleFocusIn = (event: FocusEvent) => { |
|
|
|
if (!isActiveQuestionKeyboardInput(event.target)) return; |
|
|
|
activeQuestionInput = event.target; |
|
|
|
console.log('[Coord] focusin on input:', (event.target as HTMLElement).tagName, 'lastKHeight:', lastKeyboardHeight); |
|
|
|
if (lastKeyboardHeight > KEYBOARD_THRESHOLD) { |
|
|
|
keyboardHeight = lastKeyboardHeight; |
|
|
|
const expectedHeight = |
|
|
|
lastKeyboardHeight > 250 ? lastKeyboardHeight : 330; |
|
|
|
keyboardHeight = expectedHeight; |
|
|
|
keyboardVisible = true; |
|
|
|
} |
|
|
|
console.log('[Coord] focusin on input:', (event.target as HTMLElement).tagName, 'targetKHeight:', expectedHeight); |
|
|
|
scheduleLiftUpdate(); |
|
|
|
}; |
|
|
|
|
|
|
|
@ -262,15 +260,14 @@ export function useQuestionViewportCoordinator() { |
|
|
|
activeQuestionInput = document.activeElement; |
|
|
|
keyboardVisible = true; |
|
|
|
keyboardHeight = Math.max(keyboardHeight, reduction); |
|
|
|
lastKeyboardHeight = keyboardHeight; |
|
|
|
scheduleLiftUpdate(); |
|
|
|
if (keyboardHeight > 250) { |
|
|
|
lastKeyboardHeight = Math.max(lastKeyboardHeight, keyboardHeight); |
|
|
|
} |
|
|
|
} else if (reduction <= KEYBOARD_THRESHOLD && keyboardHeight <= KEYBOARD_THRESHOLD) { |
|
|
|
keyboardVisible = false; |
|
|
|
keyboardHeight = 0; |
|
|
|
} |
|
|
|
} else if (reduction <= KEYBOARD_THRESHOLD && !keyboardVisible) { |
|
|
|
closedViewportHeight = viewportHeight; |
|
|
|
scheduleLiftUpdate(); |
|
|
|
} |
|
|
|
scheduleLiftUpdate(); |
|
|
|
}; |
|
|
|
|
|
|
|
document.addEventListener("focusin", handleFocusIn); |
|
|
|
|