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">