attempt 4 that shall surely work

This commit is contained in:
7w1 committed 2026-07-19 16:06:20 -05:00
1 parent 3c81218e3f
commit e7d08a7ecd
4 files changed
+45 -2

No files matched your search

+7 -1
View File
@@ -64,10 +64,16 @@ describe('android edge-to-edge inset contract', () => {
it('extends only standalone iOS PWAs to the dynamic viewport bottom', () => {
const indexCss = readWorkspaceFile('src/index.css');
const indexTsx = readWorkspaceFile('src/index.tsx');
const iosPwaViewport = readWorkspaceFile('src/app/utils/iosPwaViewport.ts');
expect(indexCss).toContain('@media (display-mode: standalone)');
expect(indexCss).toContain('@supports (-webkit-touch-callout: none)');
expect(indexCss).toContain('height: 100dvh');
expect(indexCss).toContain('var(--sable-ios-pwa-viewport-height, 100dvh)');
expect(indexTsx).toContain('installIosPwaViewportHeight();');
expect(iosPwaViewport).toContain("window.matchMedia('(display-mode: standalone)').matches");
expect(iosPwaViewport).toContain('viewport.height + viewport.offsetTop');
expect(iosPwaViewport).toContain("window.setTimeout(updateHeight, 350)");
});
it('removes the scattered safe-area css consumers', () => {
+35
View File
@@ -0,0 +1,35 @@
const IOS_PWA_VIEWPORT_HEIGHT = '--sable-ios-pwa-viewport-height';
const isStandaloneIosPwa = (): boolean =>
window.matchMedia('(display-mode: standalone)').matches &&
CSS.supports('-webkit-touch-callout: none');
export function installIosPwaViewportHeight(): void {
if (!isStandaloneIosPwa()) return;
let frame = 0;
let settleTimer = 0;
const updateHeight = () => {
frame = 0;
const viewport = window.visualViewport;
const height = viewport ? viewport.height + viewport.offsetTop : window.innerHeight;
document.documentElement.style.setProperty(IOS_PWA_VIEWPORT_HEIGHT, `${Math.round(height)}px`);
};
const scheduleUpdate = () => {
if (frame) cancelAnimationFrame(frame);
frame = requestAnimationFrame(updateHeight);
window.clearTimeout(settleTimer);
settleTimer = window.setTimeout(updateHeight, 350);
};
updateHeight();
window.addEventListener('resize', scheduleUpdate);
window.addEventListener('orientationchange', scheduleUpdate);
window.visualViewport?.addEventListener('resize', scheduleUpdate);
window.visualViewport?.addEventListener('scroll', scheduleUpdate);
document.addEventListener('focusin', scheduleUpdate);
document.addEventListener('focusout', scheduleUpdate);
}
+1 -1
View File
@@ -63,7 +63,7 @@ body {
html,
body,
#root {
height: 100dvh;
height: var(--sable-ios-pwa-viewport-height, 100dvh);
}
}
}
+2
View File
@@ -23,6 +23,7 @@ import { registerMatrixUriProtocol } from './app/plugins/matrix-uri';
import { initTauriMediaSession } from './app/utils/tauriMediaAuth';
import { registerAppServiceWorker } from './serviceWorkerBootstrap';
import { hasServiceWorker } from './app/utils/platform';
import { installIosPwaViewportHeight } from './app/utils/iosPwaViewport';
enableMapSet();
installConsolePasteScamWarning();
@@ -30,6 +31,7 @@ registerMatrixUriProtocol();
const log = createLogger('index');
document.body.classList.add(configClass, varsClass);
installIosPwaViewportHeight();
registerAppServiceWorker();