Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ describe("HistorySwipeNavigation", () => {
["swiping back at a shadow-root scroller's left edge navigates", "shadow", 0, -130, true],
["swiping back over a panel without overflow navigates", "none", 0, -130, true],
["a swipe that started in a closed dialog keeps the thread", "closed-dialog", 0, -130, false],
["swiping back over an open alert dialog keeps the thread", "alertdialog", 0, -130, false],
] as const)("%s", async (_name, scroller, scrollLeft, deltaX, navigates) => {
navigateHistory.mockReset();
await using screen = await render(<HistorySwipeNavigation />);
const panel = screen.container.appendChild(document.createElement("div"));
const root = scroller.startsWith("shadow") ? panel.attachShadow({ mode: "open" }) : panel;
const viewport = root.appendChild(document.createElement("div"));
const noOverflow = scroller === "none" || scroller === "closed-dialog";
const noOverflow = scroller === "none" || scroller.endsWith("dialog");
viewport.style.cssText = `width: 200px; overflow-x: ${noOverflow ? "visible" : "auto"}`;
const content = viewport.appendChild(document.createElement("div"));
content.style.cssText = `height: 20px; width: ${noOverflow ? 100 : 1000}px`;
viewport.scrollLeft = scrollLeft;
if (scroller === "alertdialog") panel.setAttribute("role", "alertdialog");

if (scroller === "closed-dialog") {
panel.setAttribute("role", "dialog");
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/components/HistorySwipeNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ function lockSwipeAxis(
): Exclude<SwipeGesture, { kind: "pending" }> {
const { path, sumX, sumY } = pending;
if (Math.abs(sumX) <= Math.abs(sumY)) return { kind: "ignored" };
if (path.some((node) => node instanceof Element && node.matches('[role="dialog"]'))) {
if (
path.some(
(node) => node instanceof Element && node.matches('[role="dialog"], [role="alertdialog"]'),
)
) {
return { kind: "ignored" };
}
if (canScrollHorizontally(path, sumX)) return { kind: "ignored" };
Expand Down
Loading