web: keep mobile composition stable across keyboard and Back navigation
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mobileViewportState } from "../src/mobileViewport.js";
|
||||
|
||||
const base = { width: 390, height: 844, baselineHeight: 844, layoutHeight: 844, editing: true };
|
||||
test("keyboard geometry follows the visual viewport without assuming dvh resizes", () => {
|
||||
assert.deepEqual(mobileViewportState({ ...base, height: 430, offsetTop: 20 }), { keyboard: true, height: 430, top: 20 });
|
||||
// Chromium's resizes-content can shrink both; the pre-focus baseline survives.
|
||||
assert.equal(mobileViewportState({ ...base, height: 430, layoutHeight: 430 }).keyboard, true);
|
||||
assert.equal(mobileViewportState({ ...base, height: 430, editing: false, wasOpen: true }).keyboard, true);
|
||||
assert.equal(mobileViewportState(base).keyboard, false);
|
||||
});
|
||||
test("toolbar motion, desktop layouts and pinch zoom never trigger keyboard layout", () => {
|
||||
assert.equal(mobileViewportState({ ...base, height: 780 }).keyboard, false);
|
||||
assert.equal(mobileViewportState({ ...base, height: 430, scale: 2 }).keyboard, false);
|
||||
assert.equal(mobileViewportState({ ...base, height: 430, width: 900 }).keyboard, false);
|
||||
assert.equal(mobileViewportState({ ...base, height: 430, editing: false }).keyboard, false);
|
||||
});
|
||||
Reference in New Issue
Block a user