mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-18 14:13:06 +00:00
fix(campanha): restore wizard links on desktop home action strip
Defer pointer capture until drag exceeds the pan threshold so Link clicks still receive pointerup and navigate to /campanha/acoes/*.
This commit is contained in:
parent
19f0fab55a
commit
f41b0fbada
2 changed files with 31 additions and 3 deletions
|
|
@ -74,9 +74,6 @@ export const CampaignHomeActionStrip = ({
|
||||||
dragging: false,
|
dragging: false,
|
||||||
}
|
}
|
||||||
suppressClickRef.current = false
|
suppressClickRef.current = false
|
||||||
if (typeof el.setPointerCapture === 'function') {
|
|
||||||
el.setPointerCapture(event.pointerId)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[isCoarsePointer],
|
[isCoarsePointer],
|
||||||
)
|
)
|
||||||
|
|
@ -94,6 +91,11 @@ export const CampaignHomeActionStrip = ({
|
||||||
if (Math.abs(deltaX) < HOME_ACTION_STRIP_DRAG_THRESHOLD_PX) return
|
if (Math.abs(deltaX) < HOME_ACTION_STRIP_DRAG_THRESHOLD_PX) return
|
||||||
session.dragging = true
|
session.dragging = true
|
||||||
setScrollerDragging(el, true)
|
setScrollerDragging(el, true)
|
||||||
|
// Capture only once pan is confirmed — capturing on pointerdown retargets
|
||||||
|
// pointerup to the scroller and child Links never receive the click (B67).
|
||||||
|
if (typeof el.setPointerCapture === 'function') {
|
||||||
|
el.setPointerCapture(event.pointerId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
el.scrollLeft = session.startScrollLeft - deltaX
|
el.scrollLeft = session.startScrollLeft - deltaX
|
||||||
|
|
|
||||||
|
|
@ -272,4 +272,30 @@ describe('CampaignHomeActionStrip', () => {
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Registrar' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Registrar' }))
|
||||||
expect(onClick).toHaveBeenCalledTimes(1)
|
expect(onClick).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('allows wizard link navigation after pointerdown/up without a drag gesture', () => {
|
||||||
|
const onLinkClick = vi.fn()
|
||||||
|
const { container } = render(
|
||||||
|
<CampaignHomeActionStrip
|
||||||
|
actions={[
|
||||||
|
{
|
||||||
|
label: 'Ajustar votos',
|
||||||
|
icon: BarChart3,
|
||||||
|
description: 'Atualizar projeção.',
|
||||||
|
href: '/campanha/acoes/atualizar-votos',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>,
|
||||||
|
)
|
||||||
|
const scroller = getScroller(container)
|
||||||
|
mockScrollerOverflow(scroller)
|
||||||
|
const link = screen.getByRole('link', { name: 'Ajustar votos' })
|
||||||
|
link.onclick = onLinkClick
|
||||||
|
|
||||||
|
fireEvent.pointerDown(link, { button: 0, clientX: 40, pointerId: 5 })
|
||||||
|
fireEvent.pointerUp(link, { pointerId: 5 })
|
||||||
|
fireEvent.click(link)
|
||||||
|
|
||||||
|
expect(onLinkClick).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue