Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed - hidden part on pwa when keyboard is open #382

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,17 @@ function Root({
const focusedElement = document.activeElement as HTMLElement;
if (isInput(focusedElement) || keyboardIsOpen.current) {
const visualViewportHeight = window.visualViewport?.height || 0;
// This is the height of the keyboard
let diffFromInitial = window.innerHeight - visualViewportHeight;

const drawerHeight = drawerRef.current.getBoundingClientRect().height || 0;
const offsetFromTop = drawerRef.current.getBoundingClientRect().top;

// This is the height of the keyboard
let diffFromInitial = drawerHeight + offsetFromTop - visualViewportHeight;

if (!initialDrawerHeight.current) {
initialDrawerHeight.current = drawerHeight;
}
const offsetFromTop = drawerRef.current.getBoundingClientRect().top;


// visualViewport height may change due to some subtle changes to the keyboard. Checking if the height changed by 60 or more will make sure that they keyboard really changed its open state.
if (Math.abs(previousDiffFromInitial.current - diffFromInitial) > 60) {
keyboardIsOpen.current = !keyboardIsOpen.current;
Expand Down