From cce9718b45be59ee7c07a48cb7b0418569f7a413 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Fri, 6 Nov 2026 15:40:36 -0700 Subject: [PATCH] Stop the sign-in page jumping when the iOS keyboard opens A sign-in page already fills the screen, so it no longer shrinks itself to the area above an on-screen keyboard. On iOS that resize fought the browser's own pan to the focused field and the form moved up and down as the keyboard opened. Dialogs still fit above the keyboard. --- src/gui/src/UI/Auth/authFlow.js | 3 +++ src/gui/src/UI/Dashboard/dashboardOverlay.js | 6 ++++-- src/gui/src/UI/Dashboard/dashboardOverlay.test.js | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/src/UI/Auth/authFlow.js b/src/gui/src/UI/Auth/authFlow.js index e6e323347..ad8eec8f2 100644 --- a/src/gui/src/UI/Auth/authFlow.js +++ b/src/gui/src/UI/Auth/authFlow.js @@ -201,6 +201,9 @@ export default function openAuthFlow ({ page = false, dismissable = ! page, clos const { $overlay, $dialog, close: closeOverlay, isClosed } = mountDashboardOverlay({ html: h, + // A page already fills the screen. Resizing it under iOS's own pan to + // the focused field makes the form jump up and down as the keyboard opens. + fitKeyboard: ! as_page, canDismiss: (via) => dismissable && (via === 'close' || (! busy && (via !== 'backdrop' || closeOnBackdrop))), onDismiss: () => { diff --git a/src/gui/src/UI/Dashboard/dashboardOverlay.js b/src/gui/src/UI/Dashboard/dashboardOverlay.js index 88b29ae76..cfeb5a8f1 100644 --- a/src/gui/src/UI/Dashboard/dashboardOverlay.js +++ b/src/gui/src/UI/Dashboard/dashboardOverlay.js @@ -72,9 +72,11 @@ export function bindBackdropDismiss ($overlay, isBackdrop, dismiss) { * overlay, after it has closed. Not called for `close()`. * @param {(via: 'escape'|'close'|'backdrop') => boolean} [opts.canDismiss] * Consulted before each dismissal; returning false keeps the overlay up. + * @param {boolean} [opts.fitKeyboard] Shrink to the part of the screen an + * on-screen keyboard leaves visible. Defaults to true. * @returns {{ $overlay: jQuery, $dialog: jQuery, close: () => void, isClosed: () => boolean }} */ -export default function mountDashboardOverlay ({ html, $container, returnFocusTo, onDismiss, canDismiss }) { +export default function mountDashboardOverlay ({ html, $container, returnFocusTo, onDismiss, canDismiss, fitKeyboard = true }) { const $root = $container && $container.length ? $container : $('body'); const ns = `.dashboard-overlay-${++overlay_seq}`; const el_previous_focus = document.activeElement; @@ -87,7 +89,7 @@ export default function mountDashboardOverlay ({ html, $container, returnFocusTo // iOS lays its keyboard over the page rather than resizing it, which // would leave a bottom sheet's fields and buttons underneath. Pin the // overlay to the part of the screen that is still visible. - const viewport = window.visualViewport; + const viewport = fitKeyboard ? window.visualViewport : null; const fitToViewport = () => { const covered = window.innerHeight - viewport.height - viewport.offsetTop; const pinned = covered > 1 || viewport.offsetTop > 1; diff --git a/src/gui/src/UI/Dashboard/dashboardOverlay.test.js b/src/gui/src/UI/Dashboard/dashboardOverlay.test.js index ac29ed48f..798410c44 100644 --- a/src/gui/src/UI/Dashboard/dashboardOverlay.test.js +++ b/src/gui/src/UI/Dashboard/dashboardOverlay.test.js @@ -150,6 +150,13 @@ describe('mountDashboardOverlay', () => { close(); expect(window.visualViewport.removeEventListener).toHaveBeenCalledWith('resize', listeners.resize); }); + + it('leaves its size alone under a keyboard when told not to fit it', () => { + window.visualViewport = { height: window.innerHeight, offsetTop: 0, addEventListener: vi.fn(), removeEventListener: vi.fn() }; + const { close } = mountDashboardOverlay({ html: card, fitKeyboard: false }); + expect(window.visualViewport.addEventListener).not.toHaveBeenCalled(); + close(); + }); }); describe('bindBackdropDismiss', () => {