Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Android 15: sheets stand on the soft keyboard, and the focused field is kept above it

Duarte Santosd2c8e7c1f865
diff --git a/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java b/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java
index fb5b5a8cb..54bf83884 100644
--- a/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java
+++ b/frontend/android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java
@@ -15,6 +15,8 @@ public class MainActivity extends BridgeActivity {
// pixels; negative until the window has said.
private float barTop = -1;
private float barBottom = -1;
+ // How much of the page the soft keyboard covers, in CSS pixels; 0 while it is down.
+ private float keyboard = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -47,7 +49,11 @@ public class MainActivity extends BridgeActivity {
float density = v.getResources().getDisplayMetrics().density;
barTop = bars.top / density;
barBottom = bars.bottom / density;
+ float kb = coveredByKeyboard(v, insets.getInsets(WindowInsetsCompat.Type.ime()).bottom) / density;
+ boolean kbChanged = kb != keyboard;
+ keyboard = kb;
applyBars(web);
+ if (kbChanged) web.evaluateJavascript(keyboardScript(keyboard), null);
return ViewCompat.onApplyWindowInsets(v, insets);
});
// A page that loads (the first one, or a reload) starts without them.
@@ -55,11 +61,28 @@ public class MainActivity extends BridgeActivity {
@Override
public void onPageLoaded(WebView view) {
applyBars(view);
+ view.evaluateJavascript(keyboardScript(keyboard), null);
}
});
ViewCompat.requestApplyInsets(holder);
}
+ /**
+ * Edge to edge, adjustResize no longer shrinks the window for the soft keyboard: the WebView
+ * keeps its full height, innerHeight and visualViewport do not move, and a bottom sheet stays
+ * under the keys. The IME inset is the keyboard's top measured from the foot of the window;
+ * whatever the system did shrink the view by (should a device still resize it) is taken off,
+ * so the page is never lifted twice.
+ */
+ static int coveredByKeyboard(View v, int imeBottom) {
+ if (imeBottom <= 0) return 0;
+ View root = v.getRootView();
+ int[] at = new int[2];
+ v.getLocationInWindow(at);
+ int below = root.getHeight() - (at[1] + v.getHeight());
+ return Math.max(0, imeBottom - Math.max(0, below));
+ }
+
private void applyBars(WebView web) {
if (barTop < 0 || barBottom < 0) return;
web.evaluateJavascript(barsScript(barTop, barBottom), null);
@@ -72,4 +95,14 @@ public class MainActivity extends BridgeActivity {
+ "e.style.setProperty('--native-sab','" + Float.toString(bottom) + "px')"
+ "})(document.documentElement)";
}
+
+ /** --native-kb on the page, and an event its sheets listen for (lib/native-keyboard.js). */
+ static String keyboardScript(float height) {
+ String px = Float.toString(height);
+ return "(function(e){if(!e)return;"
+ + "e.style.setProperty('--native-kb','" + px + "px');"
+ + "if(" + px + ">0)e.setAttribute('data-native-kb','');else e.removeAttribute('data-native-kb');"
+ + "window.dispatchEvent(new CustomEvent('opengym:native-keyboard',{detail:{height:" + px + "}}))"
+ + "})(document.documentElement)";
+ }
}
diff --git a/frontend/src/components/ui.jsx b/frontend/src/components/ui.jsx
index 3aa7f5473..cdbc1fbaa 100644
--- a/frontend/src/components/ui.jsx
+++ b/frontend/src/components/ui.jsx
@@ -15,6 +15,8 @@
import { useRef, useState, useEffect, useCallback, forwardRef } from 'react'
import Icon from './Icon.jsx'
+import { sheetKeyboardInsets } from '../lib/use-sheet-keyboard.js'
+import { NATIVE_KEYBOARD_EVENT } from '../lib/native-keyboard.js'
/* ============================ text ============================ */
@@ -343,9 +345,8 @@ function SelectSheet({ title, value, options, onChange, search, close }) {
const sheet = input?.closest('.sheet')
const viewport = window.visualViewport
if (!sheet || !viewport) return
- const visualHeight = Math.max(0, viewport.height || window.innerHeight)
- const visualBottom = (viewport.offsetTop || 0) + visualHeight
- const bottomInset = Math.max(0, window.innerHeight - visualBottom)
+ // the visual viewport, or on Android 15 the keyboard the app passes (lib/native-keyboard.js)
+ const { bottomInset, visualHeight } = sheetKeyboardInsets(window)
sheet.style.setProperty('--picker-keyboard-bottom', `${bottomInset}px`)
sheet.style.setProperty('--picker-visual-height', `${visualHeight}px`)
}, [])
@@ -360,9 +361,11 @@ function SelectSheet({ title, value, options, onChange, search, close }) {
sync()
viewport.addEventListener('resize', sync)
viewport.addEventListener('scroll', sync)
+ window.addEventListener(NATIVE_KEYBOARD_EVENT, sync)
return () => {
viewport.removeEventListener('resize', sync)
viewport.removeEventListener('scroll', sync)
+ window.removeEventListener(NATIVE_KEYBOARD_EVENT, sync)
const sheet = inputRef.current?.closest('.sheet')
sheet?.style.removeProperty('--picker-keyboard-bottom')
sheet?.style.removeProperty('--picker-visual-height')
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 2b5ab1fc3..a167187e5 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -173,6 +173,9 @@ button,.chip,.tile,.item,.wday,.cal-d,.swatch,.hm-c,.lrow,.seg button,.stp butto
padding:calc(var(--sat) + var(--conn) + 8px) var(--pad) calc(88px + var(--sab));
max-width:560px;margin:0 auto;
}
+/* Android 15 with the keyboard up: room to scroll the last field on a page above the keys.
+ The tab bar stays where it is, under the keyboard, rather than riding up on it. */
+:root[data-native-kb] #app,:root[data-native-kb] body.resting #app{padding-bottom:calc(88px + var(--native-kb))}
/* Keep the last workout controls clear of the mobile overlays without adding a second
screenful of blank scroll space. The stacked rest timer needs the larger reserve. */
body.resting #app{padding-bottom:calc(206px + var(--sab))}
@@ -1239,16 +1242,24 @@ body.chips-dragging *{cursor:inherit}
padding:8px 18px calc(20px + var(--sab));
/* A tall sheet stops short of the status bar / Dynamic Island: every cap carries the top
safe-area inset, which the layout viewport does not (viewport-fit=cover). */
- max-height:90vh;max-height:min(90vh,calc(100dvh - var(--sat) - 8px));
+ max-height:90vh;max-height:min(90vh,calc(100dvh - var(--sat) - 8px - var(--native-kb,0px)));
overflow-y:auto;scroll-padding-bottom:calc(20px + var(--sab));
animation:sheetup .34s var(--ease);
overscroll-behavior:contain;touch-action:pan-y;will-change:transform;
}
.sheet:has(.picker-search){
- bottom:var(--picker-keyboard-bottom,0px);
+ bottom:max(var(--picker-keyboard-bottom,0px),var(--native-kb,0px));
/* with the keyboard up the sheet is capped by the visual viewport — which still starts
under the notch, hence the inset here too */
- max-height:min(90vh,calc(100dvh - var(--sat) - 8px),calc(var(--picker-visual-height,100vh) - var(--sat) - 8px));
+ max-height:min(90vh,calc(100dvh - var(--sat) - 8px - var(--native-kb,0px)),calc(var(--picker-visual-height,100vh) - var(--sat) - 8px));
+}
+/* Android 15: the window is not resized for the soft keyboard, the app passes the height it
+ covers as --native-kb instead (MainActivity.keyboardScript, lib/native-keyboard.js). Every
+ sheet stands on the keyboard, and its foot drops the navigation-bar inset, which the keyboard
+ already covers. Older Android versions resize the window and never set the variable. */
+:root[data-native-kb] .sheet{
+ bottom:max(var(--picker-keyboard-bottom,0px),var(--native-kb,0px));
+ padding-bottom:20px;scroll-padding-bottom:20px;
}
:root[data-theme="light"] .sheet{background:var(--bg)}
@keyframes sheetup{from{transform:translateY(100%)}to{transform:none}}
@@ -1267,6 +1278,11 @@ body.chips-dragging *{cursor:inherit}
animation:pop .28s var(--ease);
}
:root[data-theme="light"] .center{background:#fff}
+/* a dialog with a field centres in what the Android 15 keyboard leaves */
+:root[data-native-kb] .center{
+ top:calc((100% - var(--native-kb)) / 2);
+ max-height:calc(100dvh - var(--native-kb) - 2*var(--sat) - 24px);
+}
@keyframes pop{from{transform:translate(-50%,-50%) scale(.94);opacity:0}to{transform:translate(-50%,-50%) scale(1);opacity:1}}
/* --- RIR/RPE conversion table (effort help sheet) ---
diff --git a/frontend/src/lib/native-keyboard.js b/frontend/src/lib/native-keyboard.js
new file mode 100644
index 000000000..fabf4c8aa
--- /dev/null
+++ b/frontend/src/lib/native-keyboard.js
@@ -0,0 +1,101 @@
+/* The soft keyboard on Android 15. An app that targets it is drawn edge to edge, and then
+ adjustResize no longer shrinks the window when the keyboard comes up: innerHeight and the
+ visualViewport keep their full height, so nothing on the page can tell that the bottom third
+ of the screen is keys. First-launch "Connect to my server" and Home → Body weight had their
+ inputs and buttons under the keyboard (Android QA, v1.3.9).
+
+ MainActivity.keyboardScript passes the covered height as --native-kb on <html> (CSS pixels,
+ 0px when the keyboard is down), sets data-native-kb while it is up, and fires
+ 'opengym:native-keyboard'. The stylesheet lifts sheets and pads the page by it; this module
+ keeps the focused field in view. Older Android versions still resize the window, never get
+ the variable, and read 0 here — nothing changes for them, nor in a browser or on iOS. */
+
+export const NATIVE_KEYBOARD_EVENT = 'opengym:native-keyboard'
+
+// Room left between a revealed field and the keyboard's top edge.
+const MARGIN = 16
+
+export function nativeKeyboardHeight(doc = typeof document !== 'undefined' ? document : null) {
+ const el = doc?.documentElement
+ if (!el?.style) return 0
+ const v = parseFloat(el.style.getPropertyValue('--native-kb'))
+ return Number.isFinite(v) && v > 0 ? v : 0
+}
+
+/* The part of the screen the keyboard leaves: the visual viewport where the system shrinks it,
+ the layout viewport less --native-kb where it does not, whichever is smaller. */
+export function visibleBottom(win = typeof window !== 'undefined' ? window : null) {
+ if (!win) return 0
+ const vv = win.visualViewport
+ const visual = vv ? (vv.offsetTop || 0) + (vv.height || win.innerHeight) : win.innerHeight
+ return Math.min(visual, win.innerHeight - nativeKeyboardHeight(win.document))
+}
+
+function scrollsVertically(el, win) {
+ if (!el || el.nodeType !== 1) return false
+ if (el.classList?.contains('sheet')) return true
+ const oy = win.getComputedStyle?.(el)?.overflowY
+ return (oy === 'auto' || oy === 'scroll') && el.scrollHeight > el.clientHeight
+}
+
+/* Scroll the nearest scrollable ancestor (the sheet, most often; the page otherwise) just
+ enough that `el` sits above the keyboard. Only that one scroller moves: scrollIntoView would
+ walk every ancestor and, with the layout viewport still full height, think the field visible.
+ Returns the distance scrolled, 0 when the field was already clear. */
+export function revealAboveKeyboard(el, win = typeof window !== 'undefined' ? window : null) {
+ if (!el || !win || typeof el.getBoundingClientRect !== 'function') return 0
+ const doc = win.document
+ let scroller = el.parentElement
+ while (scroller && scroller !== doc.body && scroller !== doc.documentElement && !scrollsVertically(scroller, win)) {
+ scroller = scroller.parentElement
+ }
+ const page = !scroller || scroller === doc.body || scroller === doc.documentElement
+ const r = el.getBoundingClientRect()
+ let bottom = visibleBottom(win) - MARGIN
+ let top = MARGIN
+ if (!page) {
+ const s = scroller.getBoundingClientRect()
+ bottom = Math.min(bottom, s.bottom - MARGIN)
+ top = Math.max(top, s.top + MARGIN)
+ }
+ let delta = 0
+ if (r.bottom > bottom) delta = r.bottom - bottom
+ // A tall field (a textarea) keeps its top on screen rather than its foot.
+ if (r.top - delta < top) delta = r.top - top
+ if (!delta) return 0
+ if (page) {
+ const se = doc.scrollingElement || doc.documentElement
+ const before = se.scrollTop
+ win.scrollTo?.(0, before + delta)
+ return (se.scrollTop || 0) - before || delta
+ }
+ const before = scroller.scrollTop || 0
+ scroller.scrollTop = before + delta
+ return (scroller.scrollTop || 0) - before
+}
+
+const isField = el => !!el && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName || ''))
+
+/* Installed once at start-up. Does anything only while --native-kb is above 0, so where the
+ system resizes the window (Android 14 and older, iOS, browsers) the WebView's own
+ reveal-on-focus keeps doing the work. */
+export function startNativeKeyboard(win = typeof window !== 'undefined' ? window : null) {
+ if (!win?.addEventListener) return () => {}
+ let frame = 0
+ const reveal = () => {
+ if (frame) (win.cancelAnimationFrame || clearTimeout)(frame)
+ // After the sheet has taken its new bottom: one frame for the style, one for layout.
+ frame = (win.requestAnimationFrame || (f => setTimeout(f, 16)))(() => {
+ frame = 0
+ const el = win.document.activeElement
+ if (nativeKeyboardHeight(win.document) > 0 && isField(el)) revealAboveKeyboard(el, win)
+ })
+ }
+ const onFocus = e => { if (isField(e.target)) reveal() }
+ win.addEventListener(NATIVE_KEYBOARD_EVENT, reveal)
+ win.document.addEventListener('focusin', onFocus)
+ return () => {
+ win.removeEventListener(NATIVE_KEYBOARD_EVENT, reveal)
+ win.document.removeEventListener('focusin', onFocus)
+ }
+}
diff --git a/frontend/src/lib/native-keyboard.test.js b/frontend/src/lib/native-keyboard.test.js
new file mode 100644
index 000000000..b723bcde2
--- /dev/null
+++ b/frontend/src/lib/native-keyboard.test.js
@@ -0,0 +1,136 @@
+// @vitest-environment happy-dom
+// Android 15 draws the app edge to edge, and then adjustResize no longer shrinks the window for the
+// soft keyboard: innerHeight and visualViewport stayed at 915 with the keys up, and the Connect to
+// my server address, code and Connect button, and the body-weight field, sat under the keyboard
+// (Android QA, v1.3.9). MainActivity passes the covered height as --native-kb; these check the page
+// side: the sheets lift by it, the focused field is scrolled above it, and with no variable (older
+// Android, iOS, a browser) nothing changes.
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { nativeKeyboardHeight, visibleBottom, revealAboveKeyboard, startNativeKeyboard, NATIVE_KEYBOARD_EVENT } from './native-keyboard.js'
+import { sheetKeyboardInsets } from './use-sheet-keyboard.js'
+
+const read = rel => readFileSync(new URL(rel, import.meta.url), 'utf8')
+const root = () => document.documentElement
+
+function setKeyboard(px) {
+ // what MainActivity.keyboardScript runs
+ root().style.setProperty('--native-kb', `${px}px`)
+ if (px > 0) root().setAttribute('data-native-kb', '')
+ else root().removeAttribute('data-native-kb')
+ window.dispatchEvent(new CustomEvent(NATIVE_KEYBOARD_EVENT, { detail: { height: px } }))
+}
+
+const rect = (top, height) => ({ top, bottom: top + height, height, left: 0, right: 400, width: 400, x: 0, y: top })
+
+let viewport
+beforeEach(() => {
+ Object.defineProperty(window, 'innerHeight', { configurable: true, value: 915 })
+ viewport = { height: 915, offsetTop: 0, addEventListener() {}, removeEventListener() {} }
+ Object.defineProperty(window, 'visualViewport', { configurable: true, value: viewport })
+})
+afterEach(() => {
+ root().style.removeProperty('--native-kb')
+ root().removeAttribute('data-native-kb')
+ document.body.innerHTML = ''
+})
+
+describe('the keyboard height the app passes', () => {
+ it('reads 0 with no variable, and the passed height with one', () => {
+ expect(nativeKeyboardHeight()).toBe(0)
+ setKeyboard(336.5)
+ expect(nativeKeyboardHeight()).toBe(336.5)
+ setKeyboard(0)
+ expect(nativeKeyboardHeight()).toBe(0)
+ })
+
+ it('the visible bottom is the smaller of the visual viewport and the layout viewport less the keyboard', () => {
+ expect(visibleBottom()).toBe(915)
+ setKeyboard(336) // Android 15: the viewport does not move, the variable does
+ expect(visibleBottom()).toBe(579)
+ setKeyboard(0)
+ viewport.height = 600 // older Android / iOS: the viewport shrinks, no variable
+ expect(visibleBottom()).toBe(600)
+ })
+
+ it('sheets lift by the larger of the visual-viewport inset and the native one', () => {
+ expect(sheetKeyboardInsets(window)).toEqual({ bottomInset: 0, visualHeight: 915 })
+ setKeyboard(336)
+ expect(sheetKeyboardInsets(window)).toEqual({ bottomInset: 336, visualHeight: 579 })
+ setKeyboard(0)
+ viewport.height = 600
+ expect(sheetKeyboardInsets(window)).toEqual({ bottomInset: 315, visualHeight: 600 })
+ })
+})
+
+describe('keeping the focused field above the keyboard', () => {
+ function sheetWithField(fieldTop, sheetTop = 300, sheetHeight = 615) {
+ const sheet = document.createElement('div')
+ sheet.className = 'sheet'
+ const input = document.createElement('input')
+ sheet.appendChild(input)
+ document.body.appendChild(sheet)
+ let scrollTop = 0
+ Object.defineProperty(sheet, 'scrollTop', { configurable: true, get: () => scrollTop, set: v => { scrollTop = v } })
+ sheet.getBoundingClientRect = () => rect(sheetTop, sheetHeight)
+ input.getBoundingClientRect = () => rect(fieldTop - scrollTop, 44)
+ return { sheet, input }
+ }
+
+ it('scrolls the sheet, not the page, until the field clears the keys', () => {
+ setKeyboard(336)
+ const { sheet, input } = sheetWithField(800, 200, 379) // sheet already lifted onto the keys: 200..579
+ const moved = revealAboveKeyboard(input)
+ expect(moved).toBe(800 + 44 - (579 - 16))
+ expect(sheet.scrollTop).toBe(moved)
+ expect(input.getBoundingClientRect().bottom).toBeLessThanOrEqual(579 - 16)
+ })
+
+ it('leaves a field that is already clear alone', () => {
+ setKeyboard(336)
+ const { sheet, input } = sheetWithField(260, 200, 379)
+ expect(revealAboveKeyboard(input)).toBe(0)
+ expect(sheet.scrollTop).toBe(0)
+ })
+
+ it('does it on focus and when the keyboard comes up, only while the app passes a height', async () => {
+ const stop = startNativeKeyboard()
+ try {
+ const { sheet, input } = sheetWithField(700, 200, 379)
+ input.focus()
+ await new Promise(r => requestAnimationFrame(() => setTimeout(r, 0)))
+ expect(sheet.scrollTop).toBe(0) // no keyboard variable: the system handles it
+ setKeyboard(336)
+ await new Promise(r => requestAnimationFrame(() => setTimeout(r, 0)))
+ expect(sheet.scrollTop).toBe(700 + 44 - (579 - 16))
+ } finally {
+ stop()
+ }
+ })
+})
+
+describe('the two halves agree', () => {
+ const css = read('../index.css')
+ const activity = read('../../android/app/src/main/java/ch/duartesantos/opengym/MainActivity.java')
+
+ it('the app passes the IME inset as --native-kb and fires the event', () => {
+ expect(activity).toMatch(/WindowInsetsCompat\.Type\.ime\(\)/)
+ expect(activity).toContain("'--native-kb'")
+ expect(activity).toContain("data-native-kb")
+ expect(activity).toContain(NATIVE_KEYBOARD_EVENT)
+ // still only from Android 15 on: older versions resize the window themselves
+ expect(activity).toMatch(/Build\.VERSION\.SDK_INT < 35/)
+ })
+
+ it('every sheet stands on the keyboard and the picker takes the larger lift', () => {
+ expect(css).toMatch(/:root\[data-native-kb\] \.sheet\{\s*bottom:max\(var\(--picker-keyboard-bottom,0px\),var\(--native-kb,0px\)\);/)
+ expect(css).toMatch(/\.sheet:has\(\.picker-search\)\{\s*bottom:max\(var\(--picker-keyboard-bottom,0px\),var\(--native-kb,0px\)\);/)
+ expect(css).toMatch(/max-height:min\(90vh,calc\(100dvh - var\(--sat\) - 8px - var\(--native-kb,0px\)\)\)/)
+ })
+
+ it('the tab bar is left under the keyboard', () => {
+ const tabbar = css.match(/#tabbar\{[^}]*\}/)[0]
+ expect(tabbar).not.toMatch(/native-kb/)
+ expect(css).not.toMatch(/data-native-kb\][^{]*#tabbar/)
+ })
+})
diff --git a/frontend/src/lib/use-sheet-keyboard.js b/frontend/src/lib/use-sheet-keyboard.js
index 005cb9562..eccfd6655 100644
--- a/frontend/src/lib/use-sheet-keyboard.js
+++ b/frontend/src/lib/use-sheet-keyboard.js
@@ -1,12 +1,28 @@
import { useCallback, useEffect } from 'react'
+import { nativeKeyboardHeight, NATIVE_KEYBOARD_EVENT } from './native-keyboard.js'
+
+/* How far the keyboard reaches up the layout viewport, and the height left above it. */
+export function sheetKeyboardInsets(win) {
+ const viewport = win.visualViewport
+ const native = nativeKeyboardHeight(win.document)
+ const vh = Math.max(0, viewport?.height || win.innerHeight)
+ const visualBottom = (viewport?.offsetTop || 0) + vh
+ const bottomInset = Math.max(0, win.innerHeight - visualBottom, native)
+ const visualHeight = Math.max(0, Math.min(vh, win.innerHeight - native))
+ return { bottomInset, visualHeight }
+}
/* Keyboard-aware sheets. When the mobile keyboard comes up the layout viewport keeps its
size, only the visual viewport shrinks — so a bottom sheet with a text input near its
foot ends up half under the keys. index.css reads two custom properties on the sheet
(--picker-keyboard-bottom / --picker-visual-height) to lift and cap it. SelectSheet in
- components/ui.jsx does exactly this sync inline; the exercise picker, the custom-exercise
- form and the note sheets need the same thing, hence this hook. The logic is deliberately
- duplicated rather than imported so ui.jsx keeps no public surface for it.
+ components/ui.jsx does the same sync inline; the exercise picker, the custom-exercise
+ form and the note sheets need it too, hence this hook. Both measure with
+ sheetKeyboardInsets below.
+
+ On Android 15 the visual viewport does not shrink either (the app is edge to edge, so
+ adjustResize has no effect); there the app passes the keyboard as --native-kb
+ (lib/native-keyboard.js) and the larger of the two wins.
`inputRef` points at the text input (or textarea) whose closest `.sheet` gets the vars.
`enabled` lets a caller switch the sync off (e.g. a picker without a search box). */
@@ -16,9 +32,7 @@ export function useSheetKeyboard(inputRef, enabled = true) {
const sheet = input?.closest?.('.sheet')
const viewport = typeof window !== 'undefined' ? window.visualViewport : null
if (!sheet || !viewport) return
- const visualHeight = Math.max(0, viewport.height || window.innerHeight)
- const visualBottom = (viewport.offsetTop || 0) + visualHeight
- const bottomInset = Math.max(0, window.innerHeight - visualBottom)
+ const { bottomInset, visualHeight } = sheetKeyboardInsets(window)
sheet.style.setProperty('--picker-keyboard-bottom', `${bottomInset}px`)
sheet.style.setProperty('--picker-visual-height', `${visualHeight}px`)
}, [inputRef])
@@ -30,9 +44,11 @@ export function useSheetKeyboard(inputRef, enabled = true) {
sync()
viewport.addEventListener('resize', sync)
viewport.addEventListener('scroll', sync)
+ window.addEventListener(NATIVE_KEYBOARD_EVENT, sync)
return () => {
viewport.removeEventListener('resize', sync)
viewport.removeEventListener('scroll', sync)
+ window.removeEventListener(NATIVE_KEYBOARD_EVENT, sync)
// The sheet element outlives this input when the sheet swaps content, so leave it
// the way we found it rather than pinning a stale keyboard inset on it.
const sheet = inputRef.current?.closest?.('.sheet')
diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx
index 6d4187fb0..e08383fc4 100644
--- a/frontend/src/main.jsx
+++ b/frontend/src/main.jsx
@@ -4,6 +4,7 @@ import App from './App.jsx'
import { MOBILE } from './lib/mobile.js'
import { useStore } from './store/useStore.js'
import { startMediaSync } from './lib/media-sync.js'
+import { startNativeKeyboard } from './lib/native-keyboard.js'
import './index.css'
// App.jsx restores per-route scroll itself; the browser's own attempt races it.
@@ -17,6 +18,10 @@ createRoot(document.getElementById('root')).render(
// uploads of what the server lacks, the local clean-up, and the plan's files kept offline.
startMediaSync(useStore)
+// Android 15 does not resize the page for the soft keyboard; the app says how much it covers and
+// this keeps the focused field above it. Idle everywhere else.
+startNativeKeyboard()
+
// Not in the mobile build: the native shell already serves everything from disk.
if (!MOBILE && 'serviceWorker' in navigator && location.protocol === 'https:') {
navigator.serviceWorker.register('sw.js').catch(() => {})