fix(app): D6b pen follows touch, stale press and hover guards (R1, D6b)

This commit is contained in:
bchanot committed 2026-11-12 13:42:01 +01:00
1 parent 132756eecd
commit 6ed90efb3a
2 files changed
+68 -10

No files matched your search

@@ -1112,6 +1112,7 @@ describe('a tap on the drawing (D6b)', () => {
pointerId: id,
isPrimary: true,
button: 0,
buttons: 1,
pointerType: type,
})
@@ -1255,13 +1256,59 @@ describe('a tap on the drawing (D6b)', () => {
spy.mockRestore()
})
it('a pen tap deselects at the pointer-up like a mouse', async () => {
it('the read-only twin keeps the keyboard pan and zoom', async () => {
await mountSpy({ readOnly: true })
const canvas = screen.getByTestId('catalogue-canvas')
const view = drawing(true)
fireEvent.keyDown(canvas, { key: '+' })
expect(view.style.transform).toContain('scale(1.5)')
// Handled (default prevented) by the framing's keyboard pan; the box has no size here.
expect(fireEvent.keyDown(canvas, { key: 'ArrowLeft' })).toBe(false)
})
it('a pen tap deselects in its own click, like a touch tap', async () => {
await selected()
tap(rect(), { type: 'pen' })
const hit = rect()
fireEvent.pointerDown(hit, { ...init(1, 'pen'), clientX: 10, clientY: 10 })
fireEvent.pointerUp(hit, { ...init(1, 'pen'), clientX: 10, clientY: 10 })
expect(isDeselected()).toBe(false)
fireEvent.click(hit)
expect(isDeselected()).toBe(true)
expect(announce).toHaveBeenCalledWith(DESELECTED)
})
it('a pen tap whose click lands on a marker selects that marker', async () => {
await selected({ text: insert(text(), named('anno-b', 90, 90, 3)) })
tap(rect(), { type: 'pen', upOn: marker('anno-b') })
expect(announce).not.toHaveBeenCalled()
expect(marker('anno-b')).toHaveAttribute('data-state', 'current')
expect(marker('anno-a')).not.toHaveAttribute('data-state')
})
it('a hover move after the press does not count as a drag', async () => {
await selected()
fireEvent.pointerDown(rect(), { ...init(), clientX: 10, clientY: 10 })
fireEvent.pointerMove(rect(), {
...init(),
buttons: 0,
clientX: 20,
clientY: 10,
})
fireEvent.pointerUp(rect(), { ...init(), clientX: 10, clientY: 10 })
fireEvent.click(rect())
expect(isDeselected()).toBe(true)
})
it('a new press with the same id outside the box disarms a stale press', async () => {
await selected()
fireEvent.pointerDown(rect(), { ...init(), clientX: 10, clientY: 10 })
fireEvent.pointerUp(document.body, { ...init(), clientX: 10, clientY: 10 })
fireEvent.pointerDown(document.body, { ...init(), clientX: 300, clientY: 10 })
fireEvent.pointerUp(rect(), { ...init(), clientX: 10, clientY: 10 })
fireEvent.click(rect())
expect(isDeselected()).toBe(false)
})
it('keeps a pending keyboard creation with its typed name', async () => {
await mountSpy({ text: drawnText() })
const user = userEvent.setup()
@@ -1395,6 +1442,8 @@ describe('a tap on the drawing (D6b)', () => {
tap(rect(), { type: 'touch', upOn: marker('anno-b') })
expect(announce).not.toHaveBeenCalled()
expect(isDeselected()).toBe(false)
expect(marker('anno-b')).toHaveAttribute('data-state', 'current')
expect(marker('anno-a')).not.toHaveAttribute('data-state')
})
it('a mouse tap deselects at the pointer-up and swallows the click on a marker', async () => {