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:
Francisco Ignácio Fontoura Solla 2026-07-30 01:41:21 -03:00
parent 19f0fab55a
commit f41b0fbada
2 changed files with 31 additions and 3 deletions

View file

@ -74,9 +74,6 @@ export const CampaignHomeActionStrip = ({
dragging: false,
}
suppressClickRef.current = false
if (typeof el.setPointerCapture === 'function') {
el.setPointerCapture(event.pointerId)
}
},
[isCoarsePointer],
)
@ -94,6 +91,11 @@ export const CampaignHomeActionStrip = ({
if (Math.abs(deltaX) < HOME_ACTION_STRIP_DRAG_THRESHOLD_PX) return
session.dragging = 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

View file

@ -272,4 +272,30 @@ describe('CampaignHomeActionStrip', () => {
fireEvent.click(screen.getByRole('button', { name: 'Registrar' }))
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)
})
})