Skip to content

Commit c8a2ac5

Browse files
author
=
committed
Keep mobile override sheets above the keyboard
1 parent 0727378 commit c8a2ac5

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎apps/predbat/frontend.zip‎

11 Bytes
Binary file not shown.

‎frontend/src/components/PlanTable.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@
955955
z-index: 110;
956956
width: auto;
957957
max-width: none;
958-
max-height: calc(100dvh - var(--plan-mobile-keyboard-offset, 0px));
958+
max-height: calc(100vh - var(--plan-mobile-keyboard-offset, 0px));
959959
padding: 0.8rem;
960960
padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
961961
border-radius: 1rem 1rem 0 0;

‎frontend/src/components/PlanTable.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,9 +1317,17 @@ export default function PlanTable({
13171317
}
13181318

13191319
const viewport = visualViewport as VisualViewport
1320+
let baselineHeight = viewport.height + viewport.offsetTop
13201321

13211322
function updateKeyboardOffset() {
1322-
const offset = Math.max(0, window.innerHeight - viewport.height - viewport.offsetTop)
1323+
const visibleHeight = viewport.height + viewport.offsetTop
1324+
1325+
// Mobile browsers do not agree on whether innerHeight follows the
1326+
// keyboard. Comparing the current visual viewport with its unoccluded
1327+
// height works in both a browser tab and Home Assistant's iframe.
1328+
baselineHeight = Math.max(baselineHeight, visibleHeight)
1329+
1330+
const offset = Math.max(0, baselineHeight - visibleHeight)
13231331

13241332
document.documentElement.style.setProperty('--plan-mobile-keyboard-offset', `${offset}px`)
13251333
}

0 commit comments

Comments
 (0)