feat(native): the app's own swipe back, and a way back closes the sheet on top first

WebKit's swipe from the left edge slid away a screenshot of the whole page,
closed no sheet and took every drag near the edge from the UI. Binaries from
this one turn it off and report an edgeBack feature, and the UI draws its own:
the page follows the finger, a release past a third or a flick slides it off
and goes back, anything else springs it home, with a light detent.

Open sheets now register in one overlay stack, so a way back closes the one on
top first, through its own close path (unsaved changes still ask): the edge
swipe on iOS and Android's back gesture alike.
This commit is contained in:
Maurice
2026-11-06 13:10:39 +01:00
parent f92aea80a7
commit d859e23879
11 changed files with 352 additions and 6 deletions
+36
View File
@@ -0,0 +1,36 @@
import { renderHook } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { _resetOverlayStack, closeTopOverlay, hasOpenOverlay, useOverlay } from './overlayStack';
beforeEach(() => _resetOverlayStack());
describe('overlayStack', () => {
it('closes the newest open overlay first, and reports when none is left', () => {
const first = vi.fn();
const second = vi.fn();
const a = renderHook(({ open }) => useOverlay(open, first), { initialProps: { open: true } });
renderHook(({ open }) => useOverlay(open, second), { initialProps: { open: true } });
expect(hasOpenOverlay()).toBe(true);
expect(closeTopOverlay()).toBe(true);
expect(second).toHaveBeenCalledTimes(1);
expect(first).not.toHaveBeenCalled();
a.rerender({ open: false });
a.unmount();
});
it('forgets an overlay once it closes, and uses its latest close path', () => {
const old = vi.fn();
const fresh = vi.fn();
const h = renderHook(({ open, close }) => useOverlay(open, close), { initialProps: { open: true, close: old } });
h.rerender({ open: true, close: fresh });
closeTopOverlay();
expect(fresh).toHaveBeenCalledTimes(1);
expect(old).not.toHaveBeenCalled();
h.rerender({ open: false, close: fresh });
expect(hasOpenOverlay()).toBe(false);
expect(closeTopOverlay()).toBe(false);
});
});