From 323a3425861c468b0f2516404cb68ca33800b132 Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 18 Nov 2026 13:00:11 +0100 Subject: [PATCH] fix(ui): end an anchored dialog above the tablet keyboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Final review M-2: maxHeight runs to the visual viewport's bottom, not the layout viewport's, so « Enregistrer » stays reachable while a keyboard leaves 320 px or more. New unit case beside the keyboard one. --- apps/app/src/components/ui/anchoredPlace.ts | 2 +- apps/app/tests/unit/ui.Dialog.test.tsx | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/app/src/components/ui/anchoredPlace.ts b/apps/app/src/components/ui/anchoredPlace.ts index d89cac8b..72edf0a2 100644 --- a/apps/app/src/components/ui/anchoredPlace.ts +++ b/apps/app/src/components/ui/anchoredPlace.ts @@ -29,7 +29,7 @@ export function placeOver(anchor: HTMLElement | null): AnchoredPlace | null { const top = Math.max(EDGE, box.top) const side = { left: box.left, width: box.width } if (bottom - top - EDGE >= MIN_SPACE) { - return { ...side, top, maxHeight: window.innerHeight - top - EDGE } + return { ...side, top, maxHeight: bottom - top - EDGE } } const shown = viewport?.height ?? window.innerHeight const offset = viewport?.offsetTop ?? 0 diff --git a/apps/app/tests/unit/ui.Dialog.test.tsx b/apps/app/tests/unit/ui.Dialog.test.tsx index a8c3cc6e..e85fc275 100644 --- a/apps/app/tests/unit/ui.Dialog.test.tsx +++ b/apps/app/tests/unit/ui.Dialog.test.tsx @@ -306,6 +306,25 @@ describe('Dialog anchored over a column', () => { expect(panel().style.left).toBe('900px') }) + it('a tablet keyboard leaving 320 px or more: the panel ends 12 px above it (M-2)', () => { + window.innerHeight = 800 + withViewport({ + height: 500, + offsetTop: 0, + addEventListener: () => undefined, + removeEventListener: () => undefined, + }) + const anchor = anchorAt({ left: 900, top: 140, width: 352 }) + render( + {}} title="X"> + body + , + ) + expect(panel().style.top).toBe('140px') + // 500 - 140 - 12: « Enregistrer » stays above the keyboard. + expect(panel().style.maxHeight).toBe('348px') + }) + it('without an anchor box the panel is centred, as before', () => { render( {}} title="X">