|
|
|
@ -56,7 +56,9 @@ export function computeQuestionLift({ |
|
|
|
return Math.min(Math.max(centerShift, overlapShift), maxShift); |
|
|
|
} |
|
|
|
|
|
|
|
function isKeyboardInputTarget(target: EventTarget | null): target is HTMLElement { |
|
|
|
function isKeyboardInputTarget( |
|
|
|
target: EventTarget | null, |
|
|
|
): target is HTMLElement { |
|
|
|
if (target instanceof HTMLTextAreaElement) { |
|
|
|
return !target.disabled && !target.readOnly; |
|
|
|
} |
|
|
|
@ -82,10 +84,7 @@ export function isActiveQuestionKeyboardInput( |
|
|
|
|
|
|
|
function setLift(nextLift: number) { |
|
|
|
currentLift = Math.max(0, nextLift); |
|
|
|
document.documentElement.style.setProperty( |
|
|
|
LIFT_VARIABLE, |
|
|
|
`${currentLift}px`, |
|
|
|
); |
|
|
|
document.documentElement.style.setProperty(LIFT_VARIABLE, `${currentLift}px`); |
|
|
|
document.body.classList.toggle( |
|
|
|
"question-keyboard-open", |
|
|
|
currentLift > 0 && keyboardVisible && activeQuestionInput !== null, |
|
|
|
@ -220,7 +219,8 @@ export function useQuestionViewportCoordinator() { |
|
|
|
}); |
|
|
|
|
|
|
|
const handleViewportResize = () => { |
|
|
|
const viewportHeight = window.visualViewport?.height ?? window.innerHeight; |
|
|
|
const viewportHeight = |
|
|
|
window.visualViewport?.height ?? window.innerHeight; |
|
|
|
const reduction = closedViewportHeight - viewportHeight; |
|
|
|
|
|
|
|
if (reduction > KEYBOARD_THRESHOLD) { |
|
|
|
@ -246,7 +246,10 @@ export function useQuestionViewportCoordinator() { |
|
|
|
return () => { |
|
|
|
document.removeEventListener("focusin", handleFocusIn); |
|
|
|
document.removeEventListener("focusout", handleFocusOut); |
|
|
|
window.visualViewport?.removeEventListener("resize", handleViewportResize); |
|
|
|
window.visualViewport?.removeEventListener( |
|
|
|
"resize", |
|
|
|
handleViewportResize, |
|
|
|
); |
|
|
|
unsubscribeConfig(); |
|
|
|
resetQuestionKeyboardState(); |
|
|
|
}; |
|
|
|
|