oficina / docs Public

web: a swipe closes the Format sheet when the finger lifts

Review 9 on #181. The swipe down on the sheet's head closed it on
pointermove, with the finger still down, which on iOS hands the rest
of the touch to the page under it (a tap in the document, and the
keyboard). It now closes on pointerup.

TestTheFormatSheetAndTheQuickBar's swipe checks the sheet is still open
after the moves and closed after the lift; the first failed before
this.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 72fa1ea27f395fc7eba7468a727b5d4edc263032 parent 7f68982
2 files changed, +16 −7
  • internal/docs/brand/phone.js +8 −6
  • internal/docs/phone_format_browser_test.go +8 −1
diff --git a/internal/docs/brand/phone.js b/internal/docs/brand/phone.js
index 654a845..0c1136e 100644
--- a/internal/docs/brand/phone.js
+++ b/internal/docs/brand/phone.js
@@ -253,16 +253,18 @@
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && sheetOpen() && !e.defaultPrevented) setSheet(false);
});
- // A swipe down on the grabber or the title closes it.
+ // A swipe down on the grabber or the title closes it, when the
+ // finger lifts: a sheet that left under a finger still down would
+ // hand the rest of the touch to the page (on iOS, a tap in the
+ // document, and the keyboard).
var head = sheet.querySelector("[docs-sheet-head]");
if (head) {
var startY = null;
head.addEventListener("pointerdown", function (e) { startY = e.clientY; });
- var swiped = function (e) {
- if (startY !== null && e.clientY - startY > 60) { startY = null; setSheet(false); }
- };
- head.addEventListener("pointermove", swiped);
- head.addEventListener("pointerup", function (e) { swiped(e); startY = null; });
+ head.addEventListener("pointerup", function (e) {
+ if (startY !== null && e.clientY - startY > 60) setSheet(false);
+ startY = null;
+ });
head.addEventListener("pointercancel", function () { startY = null; });
}
// From 704px there is no sheet to keep open.
diff --git a/internal/docs/phone_format_browser_test.go b/internal/docs/phone_format_browser_test.go
index 17cf1d5..adb0bd0 100644
--- a/internal/docs/phone_format_browser_test.go
+++ b/internal/docs/phone_format_browser_test.go
@@ -238,7 +238,14 @@ func TestTheFormatSheetAndTheQuickBar(t *testing.T) {
}
return command(input.DispatchTouchEvent, input.DispatchTouchEventParams{Type: kind, TouchPoints: points})
}
- run("swipe", touch(input.DispatchTouchEventTypeTouchStart, 0), touch(input.DispatchTouchEventTypeTouchMove, 30), touch(input.DispatchTouchEventTypeTouchMove, 70), touch(input.DispatchTouchEventTypeTouchMove, 100), touch(input.DispatchTouchEventTypeTouchEnd, 100), settle)
+ // It closes when the finger lifts, not while it is still down (on
+ // iOS a sheet leaving under a held finger hands the touch to the
+ // page, and the keyboard).
+ run("swipe", touch(input.DispatchTouchEventTypeTouchStart, 0), touch(input.DispatchTouchEventTypeTouchMove, 30), touch(input.DispatchTouchEventTypeTouchMove, 70), touch(input.DispatchTouchEventTypeTouchMove, 100), settle)
+ if p = probe("held"); !p.Sheet {
+ t.Error("the sheet closed under a finger still down")
+ }
+ run("lift", touch(input.DispatchTouchEventTypeTouchEnd, 100), settle)
if p = probe("swiped"); p.Sheet {
t.Error("a swipe down on the sheet's title did not close it")
}