fix(chat): stabilize Facebook keyboard fallback
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
|
||||
const baseline: ChatKeyboardViewportBaseline = {
|
||||
layoutHeight: 800,
|
||||
layoutWidth: 390,
|
||||
visualHeight: 760,
|
||||
};
|
||||
|
||||
@@ -82,9 +83,42 @@ describe("resolveChatKeyboardInset", () => {
|
||||
});
|
||||
|
||||
describe("resolveChatKeyboardFallbackInset", () => {
|
||||
it("scales with viewport height and remains bounded", () => {
|
||||
expect(resolveChatKeyboardFallbackInset(500)).toBe(276);
|
||||
expect(resolveChatKeyboardFallbackInset(800)).toBe(352);
|
||||
expect(resolveChatKeyboardFallbackInset(1_200)).toBe(396);
|
||||
it.each([
|
||||
[{ layoutWidth: 320, layoutHeight: 568 }, 256],
|
||||
[{ layoutWidth: 360, layoutHeight: 640 }, 285],
|
||||
[{ layoutWidth: 390, layoutHeight: 844 }, 316],
|
||||
[{ layoutWidth: 430, layoutHeight: 932 }, 347],
|
||||
])("fits common viewport %o", (viewport, expectedInset) => {
|
||||
expect(resolveChatKeyboardFallbackInset(viewport)).toBe(expectedInset);
|
||||
});
|
||||
|
||||
it("stays stable across tall viewports with the same width", () => {
|
||||
expect(
|
||||
resolveChatKeyboardFallbackInset({
|
||||
layoutWidth: 390,
|
||||
layoutHeight: 760,
|
||||
}),
|
||||
).toBe(316);
|
||||
expect(
|
||||
resolveChatKeyboardFallbackInset({
|
||||
layoutWidth: 390,
|
||||
layoutHeight: 900,
|
||||
}),
|
||||
).toBe(316);
|
||||
});
|
||||
|
||||
it("keeps the keyboard estimate within its bounds", () => {
|
||||
expect(
|
||||
resolveChatKeyboardFallbackInset({
|
||||
layoutWidth: 300,
|
||||
layoutHeight: 400,
|
||||
}),
|
||||
).toBe(256);
|
||||
expect(
|
||||
resolveChatKeyboardFallbackInset({
|
||||
layoutWidth: 600,
|
||||
layoutHeight: 1_000,
|
||||
}),
|
||||
).toBe(356);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user