makethisbetter 1.14.2 → 1.14.3

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.
@@ -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,OAAO,CAA2B;IAC1C,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,iBAAiB,CAAqC;IAC9D,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,mBAAmB,CAAmC;IAC9D,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,iBAAiB,CAA0B;I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AAC,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"}
@@ -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"}
@@ -14,15 +14,19 @@
14
14
  *
15
15
  * The host page is not ours, so its own inline values are saved and put back
16
16
  * verbatim. Writing '' on unlock would silently delete a style the page set.
17
+ *
18
+ * Deliberately does NOT pin the scroll offset. An earlier version listened for
19
+ * scroll and snapped the page back, as insurance against anything scrolling it
20
+ * programmatically. On a real phone that is harmful: rubber-banding fires
21
+ * scroll events as the finger lands, the snap-back moves content mid-gesture,
22
+ * and the browser answers by cancelling the pointer — so the tap never reaches
23
+ * pointerup and no pin is placed. focus({ preventScroll: true }) addresses the
24
+ * one thing that actually scrolled the page.
17
25
  */
18
26
  export declare class ScrollLock {
19
27
  private locked;
20
28
  private prevOverflow;
21
29
  private prevTouchAction;
22
- private anchorX;
23
- private anchorY;
24
- private onScroll;
25
- private isTouchPointer;
26
30
  lock(): void;
27
31
  unlock(): void;
28
32
  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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAAK;IAE5B,IAAI,IAAI,IAAI;IASZ,MAAM,IAAI,IAAI;IAOd,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.3",
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,13 @@
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"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@vitest/coverage-v8": "^1.5.0",
41
42
  "jsdom": "^24.0.0",
43
+ "playwright": "^1.62.0",
42
44
  "typescript": "^5.4.0",
43
45
  "vite": "^5.2.0",
44
46
  "vitest": "^1.5.0"
@@ -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
 
@@ -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
  *
@@ -14,47 +16,32 @@
14
16
  *
15
17
  * The host page is not ours, so its own inline values are saved and put back
16
18
  * verbatim. Writing '' on unlock would silently delete a style the page set.
19
+ *
20
+ * Deliberately does NOT pin the scroll offset. An earlier version listened for
21
+ * scroll and snapped the page back, as insurance against anything scrolling it
22
+ * programmatically. On a real phone that is harmful: rubber-banding fires
23
+ * scroll events as the finger lands, the snap-back moves content mid-gesture,
24
+ * and the browser answers by cancelling the pointer — so the tap never reaches
25
+ * pointerup and no pin is placed. focus({ preventScroll: true }) addresses the
26
+ * one thing that actually scrolled the page.
17
27
  */
18
28
  export class ScrollLock {
19
29
  private locked = false
20
30
  private prevOverflow = ''
21
31
  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
- }
40
32
 
41
33
  lock(): void {
42
- if (this.locked || !this.isTouchPointer()) return
34
+ if (this.locked || !isTouchPointer()) return
43
35
  this.locked = true
44
36
  this.prevOverflow = document.body.style.overflow
45
37
  this.prevTouchAction = document.body.style.touchAction
46
38
  document.body.style.overflow = 'hidden'
47
39
  document.body.style.touchAction = 'none'
48
-
49
- this.anchorX = window.scrollX
50
- this.anchorY = window.scrollY
51
- window.addEventListener('scroll', this.onScroll, { passive: true })
52
40
  }
53
41
 
54
42
  unlock(): void {
55
43
  if (!this.locked) return
56
44
  this.locked = false
57
- window.removeEventListener('scroll', this.onScroll)
58
45
  document.body.style.overflow = this.prevOverflow
59
46
  document.body.style.touchAction = this.prevTouchAction
60
47
  }