fix(ui): end an anchored dialog above the tablet keyboard
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.
This commit is contained in:
1 parent
9e1ec4479d
commit
323a342586
2 files changed
+20
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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(
|
||||
<Dialog open anchor={anchor} onClose={() => {}} title="X">
|
||||
body
|
||||
</Dialog>,
|
||||
)
|
||||
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(
|
||||
<Dialog open anchor={{ current: null }} onClose={() => {}} title="X">
|
||||
|
||||
Reference in new issue
Block a user