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', () => {