makethisbetter 1.14.2 → 1.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,7 @@ interface PopupOptions {
15
15
  export declare class CommentPopup {
16
16
  private el;
17
17
  private sheet;
18
+ private releaseGuard;
18
19
  private textarea;
19
20
  private submitBtn;
20
21
  private errorEl;
@@ -1 +1 @@
1
- {"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../src/popup/comment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAI1C,UAAU,YAAY;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,QAAQ,EAAE,YAAY,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAC5B;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,mBAAmB,CA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OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,mBAAmB,CAAsB;gBAErC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY;IA6BvD,OAAO,CAAC,SAAS;IA6CjB,OAAO,CAAC,aAAa;IAkDrB,OAAO,CAAC,UAAU;IAoClB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,MAAM;IAOd,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAclC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK/B,cAAc,IAAI,cAAc;IAUhC,OAAO,IAAI,IAAI;CAMhB"}
@@ -18,6 +18,7 @@
18
18
  */
19
19
  export declare class KeyboardInset {
20
20
  private onChange;
21
+ private timer;
21
22
  private handler;
22
23
  current(): number;
23
24
  observe(onChange: (inset: number) => void): void;
@@ -1 +1 @@
1
- {"version":3,"file":"keyboard-inset.d.ts","sourceRoot":"","sources":["../../src/popup/keyboard-inset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,OAAO,CAEd;IAED,OAAO,IAAI,MAAM;IAMjB,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAShD,IAAI,IAAI,IAAI;CAOb"}
1
+ {"version":3,"file":"keyboard-inset.d.ts","sourceRoot":"","sources":["../../src/popup/keyboard-inset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkBH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,KAAK,CAA6C;IAE1D,OAAO,CAAC,OAAO,CAMd;IAED,OAAO,IAAI,MAAM;IAOjB,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAShD,IAAI,IAAI,IAAI;CAWb"}
@@ -0,0 +1,2 @@
1
+ export declare function guardReplayClick(el: HTMLElement, delay?: number): () => void;
2
+ //# sourceMappingURL=replay-click-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-click-guard.d.ts","sourceRoot":"","sources":["../../src/popup/replay-click-guard.ts"],"names":[],"mappings":"AAiBA,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,GAAE,MAAyB,GAAG,MAAM,IAAI,CAW9F"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=replay-click-guard.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-click-guard.test.d.ts","sourceRoot":"","sources":["../../src/popup/replay-click-guard.test.ts"],"names":[],"mappings":""}
@@ -44,6 +44,14 @@ export declare class WidgetController {
44
44
  private handleToolbarModeChange;
45
45
  private handleRecordStop;
46
46
  private handleDrawStroke;
47
+ /**
48
+ * The note sheet for a finished drawing on touch.
49
+ *
50
+ * Cancel here means "throw the drawing away and keep annotating", not "close
51
+ * the widget" — the reporter is mid-task and a stray stroke should cost one
52
+ * tap, not the whole session.
53
+ */
54
+ private showDrawSheet;
47
55
  private handleDrawUndoRedo;
48
56
  private refreshDrawBar;
49
57
  private cancelDraw;
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/widget/controller.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,oBAAoB,EAAqD,MAAM,UAAU,CAAA;AA8BvG,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,GAAG,CAA2B;IACtC,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC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ACxD,OAAO,CAAC,gBAAgB,CAAyC;IACjE,OAAO,CAAC,iBAAiB,CAAI;IAC7B,OAAO,CAAC,WAAW,CAAyE;gBAEhF,MAAM,EAAE,oBAAoB;IAoBxC,OAAO,CAAC,aAAa,CAuBpB;IAED,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,QAAQ;IAWhB,gFAAgF;IAChF,IAAI,IAAI,IAAI;IAMZ,KAAK,IAAI,IAAI;IAKb,YAAY,IAAI,IAAI;IAKpB,YAAY,IAAI,IAAI;IAQpB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM/B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,uBAAuB;IAwC/B,OAAO,CAAC,gBAAgB,CAKvB;IAED,OAAO,CAAC,gBAAgB;IAuBxB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,sBAAsB;YAYhB,YAAY;YAyCZ,kBAAkB;IAgDhC,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,WAAW;YA0BL,kBAAkB;IAsBhC,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,OAAO;IA+Bf,OAAO,IAAI,IAAI;CAahB"}
@@ -1,8 +1,9 @@
1
1
  import type { ShadowContainer } from './shadow';
2
2
  export declare class DimOverlay {
3
3
  private el;
4
+ private bornAt;
4
5
  private onClick;
5
- constructor(shadow: ShadowContainer, onClick: () => void);
6
+ constructor(shadow: ShadowContainer, onDismiss: () => void, now?: () => number);
6
7
  destroy(): void;
7
8
  }
8
9
  //# sourceMappingURL=dim-overlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dim-overlay.d.ts","sourceRoot":"","sources":["../../src/widget/dim-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAI/C,qBAAa,UAAU;IACrB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO,CAAC,OAAO,CAAY;gBAEf,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,IAAI;IAOxD,OAAO,IAAI,IAAI;CAIhB"}
1
+ {"version":3,"file":"dim-overlay.d.ts","sourceRoot":"","sources":["../../src/widget/dim-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAiB/C,qBAAa,UAAU;IACrB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,OAAO,CAAoB;gBAEvB,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,EAAE,GAAG,GAAE,MAAM,MAAyB;IAWhG,OAAO,IAAI,IAAI;CAIhB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether a finger is driving, rather than a mouse.
3
+ *
4
+ * Several behaviours fork on this — freezing the host page, which input
5
+ * surface collects a note — and they have to agree, so the question is asked
6
+ * in exactly one place.
7
+ *
8
+ * No matchMedia means no evidence of a touch device: assume a mouse and leave
9
+ * the desktop path alone, which is the one that already worked.
10
+ */
11
+ export declare function isTouchPointer(): boolean;
12
+ //# sourceMappingURL=pointer-kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer-kind.d.ts","sourceRoot":"","sources":["../../src/widget/pointer-kind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
@@ -12,17 +12,27 @@
12
12
  * has. Taking that away would be an unasked-for change to the one path that
13
13
  * already worked.
14
14
  *
15
+ * The lock goes on <html> as well as <body>. On iOS the scrolling element is
16
+ * the document element, so overflow: hidden on body alone does nothing —
17
+ * verified on an iOS 18.7 device, where the page scrolled ~180px while the
18
+ * lock reported itself as held.
19
+ *
15
20
  * The host page is not ours, so its own inline values are saved and put back
16
21
  * verbatim. Writing '' on unlock would silently delete a style the page set.
22
+ *
23
+ * Deliberately does NOT pin the scroll offset. An earlier version listened for
24
+ * scroll and snapped the page back, as insurance against anything scrolling it
25
+ * programmatically. On a real phone that is harmful: rubber-banding fires
26
+ * scroll events as the finger lands, the snap-back moves content mid-gesture,
27
+ * and the browser answers by cancelling the pointer — so the tap never reaches
28
+ * pointerup and no pin is placed. focus({ preventScroll: true }) addresses the
29
+ * one thing that actually scrolled the page.
17
30
  */
18
31
  export declare class ScrollLock {
19
32
  private locked;
20
33
  private prevOverflow;
21
34
  private prevTouchAction;
22
- private anchorX;
23
- private anchorY;
24
- private onScroll;
25
- private isTouchPointer;
35
+ private prevRootOverflow;
26
36
  lock(): void;
27
37
  unlock(): void;
28
38
  isLocked(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-lock.d.ts","sourceRoot":"","sources":["../../src/widget/scroll-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,OAAO,CAAI;IAMnB,OAAO,CAAC,QAAQ,CAIf;IAID,OAAO,CAAC,cAAc;IAItB,IAAI,IAAI,IAAI;IAaZ,MAAM,IAAI,IAAI;IAQd,QAAQ,IAAI,OAAO;CAGpB"}
1
+ {"version":3,"file":"scroll-lock.d.ts","sourceRoot":"","sources":["../../src/widget/scroll-lock.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,gBAAgB,CAAK;IAE7B,IAAI,IAAI,IAAI;IAWZ,MAAM,IAAI,IAAI;IAQd,QAAQ,IAAI,OAAO;CAGpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makethisbetter",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "Make This Better JS Widget SDK — embed user feedback collection in any website",
5
5
  "type": "module",
6
6
  "main": "./dist/makethisbetter.cjs",
@@ -34,11 +34,14 @@
34
34
  "test": "vitest run",
35
35
  "test:watch": "vitest",
36
36
  "type-check": "tsc --noEmit",
37
- "lint": "tsc --noEmit"
37
+ "lint": "tsc --noEmit",
38
+ "test:touch": "node e2e/touch.spec.mjs",
39
+ "test:device": "node e2e/server.mjs"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@vitest/coverage-v8": "^1.5.0",
41
43
  "jsdom": "^24.0.0",
44
+ "playwright": "^1.62.0",
42
45
  "typescript": "^5.4.0",
43
46
  "vite": "^5.2.0",
44
47
  "vitest": "^1.5.0"
@@ -3,6 +3,8 @@ import type { I18nMessages } from '../i18n'
3
3
  import type { TargetRect } from '../types'
4
4
  import { escapeHtml } from '../context/dom-utils'
5
5
  import { SheetLayout } from './sheet'
6
+ import { guardReplayClick } from './replay-click-guard'
7
+ import { isTouchPointer } from '../widget/pointer-kind'
6
8
 
7
9
  interface PopupOptions {
8
10
  targetName: string
@@ -19,6 +21,7 @@ interface PopupOptions {
19
21
  export class CommentPopup {
20
22
  private el: HTMLDivElement
21
23
  private sheet: SheetLayout
24
+ private releaseGuard: (() => void) | null = null
22
25
  private textarea!: HTMLTextAreaElement
23
26
  private submitBtn!: HTMLButtonElement
24
27
  private errorEl!: HTMLDivElement
@@ -39,6 +42,9 @@ export class CommentPopup {
39
42
  this.el.innerHTML = this.buildHTML(opts)
40
43
  shadow.append(this.el)
41
44
  this.sheet = new SheetLayout(this.el)
45
+ // The tap that opened this panel is replayed as a click once the panel is
46
+ // already under the finger — on iOS it landed on the button row.
47
+ if (isTouchPointer()) this.releaseGuard = guardReplayClick(this.el)
42
48
 
43
49
  this.textarea = this.el.querySelector('.mtb-textarea')!
44
50
  this.submitBtn = this.el.querySelector('.mtb-submit-btn')!
@@ -221,6 +227,8 @@ export class CommentPopup {
221
227
  }
222
228
 
223
229
  releaseElement(): HTMLDivElement {
230
+ this.releaseGuard?.()
231
+ this.releaseGuard = null
224
232
  // Ownership of the element passes to the caller, which means destroy() will
225
233
  // never run for this instance. Stop observing here or the listener outlives
226
234
  // the popup and keeps writing `bottom` on an element it no longer manages.
@@ -229,6 +237,8 @@ export class CommentPopup {
229
237
  }
230
238
 
231
239
  destroy(): void {
240
+ this.releaseGuard?.()
241
+ this.releaseGuard = null
232
242
  this.sheet.release()
233
243
  this.el.remove()
234
244
  }
@@ -16,16 +16,40 @@
16
16
  * as well as shrinking it, and ignoring the shift leaves the sheet floating
17
17
  * exactly that far off, with a strip of page showing beneath it.
18
18
  */
19
+
20
+ /**
21
+ * The keyboard slides in, and iOS reports the viewport continuously while it
22
+ * moves. Measured on an iOS 18.7 device over 130ms: 660 -> 323 -> 95 -> 660.
23
+ * Acting on each of those walked the sheet up to 337px, then 565px — off the
24
+ * top of the screen — and back down. Waiting for the numbers to stop moving
25
+ * turns that into one placement.
26
+ */
27
+ const SETTLE_MS = 140
28
+
29
+ /**
30
+ * No keyboard occupies most of the screen. A larger reading is a frame from
31
+ * mid-animation, and obeying it puts the sheet somewhere the reporter cannot
32
+ * see or reach.
33
+ */
34
+ const MAX_INSET_RATIO = 0.6
35
+
19
36
  export class KeyboardInset {
20
37
  private onChange: ((inset: number) => void) | null = null
38
+ private timer: ReturnType<typeof setTimeout> | null = null
39
+
21
40
  private handler = (): void => {
22
- this.onChange?.(this.current())
41
+ if (this.timer !== null) clearTimeout(this.timer)
42
+ this.timer = setTimeout(() => {
43
+ this.timer = null
44
+ this.onChange?.(this.current())
45
+ }, SETTLE_MS)
23
46
  }
24
47
 
25
48
  current(): number {
26
49
  const vp = window.visualViewport
27
50
  if (!vp) return 0
28
- return Math.max(0, Math.round(window.innerHeight - (vp.height + vp.offsetTop)))
51
+ const raw = Math.max(0, Math.round(window.innerHeight - (vp.height + vp.offsetTop)))
52
+ return raw > window.innerHeight * MAX_INSET_RATIO ? 0 : raw
29
53
  }
30
54
 
31
55
  observe(onChange: (inset: number) => void): void {
@@ -40,6 +64,10 @@ export class KeyboardInset {
40
64
  stop(): void {
41
65
  const vp = window.visualViewport
42
66
  this.onChange = null
67
+ if (this.timer !== null) {
68
+ clearTimeout(this.timer)
69
+ this.timer = null
70
+ }
43
71
  if (!vp) return
44
72
  vp.removeEventListener('resize', this.handler)
45
73
  vp.removeEventListener('scroll', this.handler)
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Blocks the compatibility click that a touch browser replays from the tap
3
+ * which opened a panel.
4
+ *
5
+ * On iOS the sequence is pointerdown / pointerup — the widget places a pin and
6
+ * opens the sheet — and only then does the browser dispatch a `click` for that
7
+ * same finger press. By that point the sheet is on screen under the touch
8
+ * point, so the click lands inside it. Observed on iOS 18.7 hitting the button
9
+ * row: a few pixels either way and the gesture that opened the sheet would
10
+ * have cancelled or submitted it.
11
+ *
12
+ * Cancelling pointerdown does not prevent this — WebKit dispatches the click
13
+ * regardless. Ignoring pointer events for a beat does, and costs nothing: a
14
+ * deliberate press is always a separate, later gesture.
15
+ */
16
+ const REPLAY_WINDOW_MS = 400
17
+
18
+ export function guardReplayClick(el: HTMLElement, delay: number = REPLAY_WINDOW_MS): () => void {
19
+ const previous = el.style.pointerEvents
20
+ el.style.pointerEvents = 'none'
21
+ const timer = setTimeout(() => {
22
+ el.style.pointerEvents = previous
23
+ }, delay)
24
+
25
+ return () => {
26
+ clearTimeout(timer)
27
+ el.style.pointerEvents = previous
28
+ }
29
+ }
@@ -3,6 +3,7 @@ import { FeedbackTab } from './tab'
3
3
  import { FrustrationPromptCard } from './frustration-prompt'
4
4
  import { DimOverlay } from './dim-overlay'
5
5
  import { ScrollLock } from './scroll-lock'
6
+ import { isTouchPointer } from './pointer-kind'
6
7
  import { AnnotationToolbar } from '../annotate/toolbar'
7
8
  import type { ToolbarMode } from '../annotate/toolbar'
8
9
  import { AnnotationSession } from '../annotate/session'
@@ -299,6 +300,15 @@ export class WidgetController {
299
300
  }
300
301
 
301
302
  private handleDrawStroke(): void {
303
+ // The draw note bar packs a field, undo/redo, cancel and submit into one
304
+ // pill at the bottom of the screen — which on a phone is exactly where the
305
+ // keyboard lands, and none of it is thumb-sized. Touch collects the note in
306
+ // the same bottom sheet the pin flow already uses.
307
+ if (isTouchPointer()) {
308
+ this.showDrawSheet()
309
+ return
310
+ }
311
+
302
312
  if (this.mode !== 'drawing') {
303
313
  this.mode = 'drawing'
304
314
  this.drawBar = new DrawNoteBar(this.shadow, {
@@ -312,6 +322,32 @@ export class WidgetController {
312
322
  this.refreshDrawBar()
313
323
  }
314
324
 
325
+ /**
326
+ * The note sheet for a finished drawing on touch.
327
+ *
328
+ * Cancel here means "throw the drawing away and keep annotating", not "close
329
+ * the widget" — the reporter is mid-task and a stray stroke should cost one
330
+ * tap, not the whole session.
331
+ */
332
+ private showDrawSheet(): void {
333
+ if (this.mode === 'drawing') return
334
+ this.mode = 'drawing'
335
+ // No dismissInteraction and no scrim here, matching the desktop draw bar:
336
+ // the overlay stays live so more strokes are still possible, and the scrim
337
+ // sits below it anyway so it could never receive the tap.
338
+
339
+ this.popup = new CommentPopup(this.shadow, {
340
+ targetName: this.messages.annotation.drawing,
341
+ x: window.innerWidth / 2,
342
+ y: window.innerHeight / 2,
343
+ messages: this.messages,
344
+ onSubmit: (description) => this.handleDrawSubmit(description),
345
+ onClose: () => this.cancelDraw(),
346
+ position: this.config.position ?? 'right',
347
+ })
348
+ this.submittingUi = this.popup
349
+ }
350
+
315
351
  private handleDrawUndoRedo(action: 'undo' | 'redo'): void {
316
352
  if (action === 'undo') this.session?.undoDraw()
317
353
  else this.session?.redoDraw()
@@ -326,6 +362,13 @@ export class WidgetController {
326
362
  private cancelDraw(): void {
327
363
  this.session?.clearDraw()
328
364
  this.teardownDraw()
365
+ // On touch the sheet is the note surface, so cancelling the drawing has to
366
+ // take the sheet and its scrim with it — teardownDraw only knows the bar.
367
+ this.popup?.destroy()
368
+ this.popup = null
369
+ this.dim?.destroy()
370
+ this.dim = null
371
+ this.submittingUi = null
329
372
  this.mode = 'annotating'
330
373
  }
331
374
 
@@ -343,7 +386,9 @@ export class WidgetController {
343
386
  this.currentAnnotation = annotation
344
387
  this.via = 'draw'
345
388
  this.session?.dismissInteraction()
346
- this.submittingUi = this.drawBar
389
+ // Whichever surface collected the note is the one that shows progress and
390
+ // errors: the inline bar on a desktop, the sheet on touch.
391
+ this.submittingUi = this.drawBar ?? this.popup
347
392
  void this.handleSubmit(note || this.messages.annotation.drawing)
348
393
  }
349
394
 
@@ -1,13 +1,31 @@
1
1
  import type { ShadowContainer } from './shadow'
2
2
 
3
+ /**
4
+ * A touch browser replays the tap that opened the popup as a compatibility
5
+ * click a moment after pointerup — and by then this scrim exists underneath,
6
+ * so that click dismissed the popup the same gesture had just opened. On a
7
+ * phone it read as the sheet flashing and vanishing, or as tapping doing
8
+ * nothing at all. Cancelling pointerdown does not prevent it: WebKit still
9
+ * dispatches the click (observed on iOS 18.7).
10
+ *
11
+ * So the scrim ignores anything that arrives before it could plausibly be a
12
+ * new gesture. A deliberate dismissal is a separate press, well past this.
13
+ */
14
+ const SPAWN_CLICK_GRACE_MS = 400
15
+
3
16
  // Full-screen scrim shown behind the comment popup. Clicking it resets the
4
17
  // widget, mirroring the design's dim-to-dismiss behaviour.
5
18
  export class DimOverlay {
6
19
  private el: HTMLDivElement
7
- private onClick: () => void
20
+ private bornAt = Date.now()
21
+ private onClick: (e: Event) => void
8
22
 
9
- constructor(shadow: ShadowContainer, onClick: () => void) {
10
- this.onClick = onClick
23
+ constructor(shadow: ShadowContainer, onDismiss: () => void, now: () => number = () => Date.now()) {
24
+ this.bornAt = now()
25
+ this.onClick = () => {
26
+ if (now() - this.bornAt < SPAWN_CLICK_GRACE_MS) return
27
+ onDismiss()
28
+ }
11
29
  this.el = shadow.el<HTMLDivElement>('div', 'mtb-dim mtb-dim-clickable')
12
30
  this.el.addEventListener('click', this.onClick)
13
31
  shadow.append(this.el)
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Whether a finger is driving, rather than a mouse.
3
+ *
4
+ * Several behaviours fork on this — freezing the host page, which input
5
+ * surface collects a note — and they have to agree, so the question is asked
6
+ * in exactly one place.
7
+ *
8
+ * No matchMedia means no evidence of a touch device: assume a mouse and leave
9
+ * the desktop path alone, which is the one that already worked.
10
+ */
11
+ export function isTouchPointer(): boolean {
12
+ return window.matchMedia?.('(pointer: coarse)').matches ?? false
13
+ }
@@ -1,3 +1,5 @@
1
+ import { isTouchPointer } from './pointer-kind'
2
+
1
3
  /**
2
4
  * Freezes the host page while a finger is annotating.
3
5
  *
@@ -12,51 +14,45 @@
12
14
  * has. Taking that away would be an unasked-for change to the one path that
13
15
  * already worked.
14
16
  *
17
+ * The lock goes on <html> as well as <body>. On iOS the scrolling element is
18
+ * the document element, so overflow: hidden on body alone does nothing —
19
+ * verified on an iOS 18.7 device, where the page scrolled ~180px while the
20
+ * lock reported itself as held.
21
+ *
15
22
  * The host page is not ours, so its own inline values are saved and put back
16
23
  * verbatim. Writing '' on unlock would silently delete a style the page set.
24
+ *
25
+ * Deliberately does NOT pin the scroll offset. An earlier version listened for
26
+ * scroll and snapped the page back, as insurance against anything scrolling it
27
+ * programmatically. On a real phone that is harmful: rubber-banding fires
28
+ * scroll events as the finger lands, the snap-back moves content mid-gesture,
29
+ * and the browser answers by cancelling the pointer — so the tap never reaches
30
+ * pointerup and no pin is placed. focus({ preventScroll: true }) addresses the
31
+ * one thing that actually scrolled the page.
17
32
  */
18
33
  export class ScrollLock {
19
34
  private locked = false
20
35
  private prevOverflow = ''
21
36
  private prevTouchAction = ''
22
- private anchorX = 0
23
- private anchorY = 0
24
-
25
- // overflow: hidden only stops the *user* scrolling. Anything the browser
26
- // does on its own still moves the page — focusing a field inside the fixed
27
- // sheet was enough to scroll the document out from under the reporter, who
28
- // then could not scroll back. Pin the offset for as long as we hold the lock.
29
- private onScroll = (): void => {
30
- if (window.scrollX !== this.anchorX || window.scrollY !== this.anchorY) {
31
- window.scrollTo(this.anchorX, this.anchorY)
32
- }
33
- }
34
-
35
- // No matchMedia means no evidence of a touch device — assume a mouse and
36
- // leave the host page alone.
37
- private isTouchPointer(): boolean {
38
- return window.matchMedia?.('(pointer: coarse)').matches ?? false
39
- }
37
+ private prevRootOverflow = ''
40
38
 
41
39
  lock(): void {
42
- if (this.locked || !this.isTouchPointer()) return
40
+ if (this.locked || !isTouchPointer()) return
43
41
  this.locked = true
44
42
  this.prevOverflow = document.body.style.overflow
45
43
  this.prevTouchAction = document.body.style.touchAction
44
+ this.prevRootOverflow = document.documentElement.style.overflow
46
45
  document.body.style.overflow = 'hidden'
47
46
  document.body.style.touchAction = 'none'
48
-
49
- this.anchorX = window.scrollX
50
- this.anchorY = window.scrollY
51
- window.addEventListener('scroll', this.onScroll, { passive: true })
47
+ document.documentElement.style.overflow = 'hidden'
52
48
  }
53
49
 
54
50
  unlock(): void {
55
51
  if (!this.locked) return
56
52
  this.locked = false
57
- window.removeEventListener('scroll', this.onScroll)
58
53
  document.body.style.overflow = this.prevOverflow
59
54
  document.body.style.touchAction = this.prevTouchAction
55
+ document.documentElement.style.overflow = this.prevRootOverflow
60
56
  }
61
57
 
62
58
  isLocked(): boolean {