fix(todo): stop the press-scale animation from swallowing checkbox clicks (#2158)

This commit is contained in:
Maurice
2026-09-01 14:42:03 +02:00
committed by Maurice
parent 0a3ba7a4d7
commit 354a89f25b
4 changed files with 37 additions and 2 deletions
@@ -1627,6 +1627,9 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
// own, hence the key handler only answers for the row — and it
// toggles exactly like the click, rather than only selecting.
role="button"
// No press-scale on the wide row — it would shift the nested
// buttons out from under the pointer mid-click (#2158).
data-no-press
tabIndex={0}
onClick={() => toggleDaySelection()}
onKeyDown={e => {
@@ -1953,8 +1956,10 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
// Picking the place out of the day has no other trigger, so
// the row is the control. Its grip, lock and arrows are
// buttons in their own right, hence the key handler only
// answers for the row itself.
// answers for the row itself. No press-scale — see the
// day header above (#2158).
role="button"
data-no-press
tabIndex={0}
draggable={canEditDays && !dragDisabled}
onDragStart={e => {
@@ -2336,7 +2341,9 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
<div
// Opening the booking has no other trigger, so the row is
// the control; the buttons inside it answer for themselves.
// No press-scale — see the day header above (#2158).
role="button"
data-no-press
tabIndex={0}
onClick={openTransportRow}
onKeyDown={e => {
@@ -614,6 +614,9 @@ function TransitJourneyCard({ r, days, onOpen, onDelete, canEdit, tripId, contri
className="bg-surface-card"
onClick={() => onOpen(r)}
role="button"
// No press-scale on the card — it would shift the nested controls out
// from under the pointer mid-click (#2158).
data-no-press
tabIndex={0}
onKeyDown={e => { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); onOpen(r) } }}
style={{ borderRadius: 12, border: '1px solid rgba(124,58,237,0.22)', padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 9, cursor: 'pointer', transition: 'box-shadow 0.15s ease' }}
+22 -1
View File
@@ -1,4 +1,4 @@
// FE-W4TDR-001 to FE-W4TDR-020
// FE-W4TDR-001 to FE-W4TDR-022
import type { ComponentProps } from 'react'
import { describe, it, expect, vi } from 'vitest'
import type { TodoItem } from '../../types'
@@ -207,4 +207,25 @@ describe('TodoRow', () => {
)
expect((container.firstElementChild as HTMLElement).style.boxShadow).toBe('inset 3px 0 0 0 var(--accent)')
})
it('FE-W4TDR-021: the row opts out of the global press-scale (#2158)', () => {
// jsdom cannot replay the browser mechanics behind #2158: the :active
// scale on the row-wide role="button" shifted the checkbox out from under
// the pointer, so the click retargeted onto the row and opened the detail
// pane instead of toggling. The data-no-press attribute is the pin.
const { container } = setup(todo())
expect(container.firstElementChild).toHaveAttribute('data-no-press')
})
it('FE-W4TDR-022: the checkbox toggles without selecting or starting a drag', () => {
const drag = dragHandlers()
const { onToggle, onSelect, container } = setup(todo(), { drag })
fireEvent.click(container.querySelector('button')!)
expect(onToggle).toHaveBeenCalledWith(10, true)
expect(onSelect).not.toHaveBeenCalled()
expect(drag.onStart).not.toHaveBeenCalled()
})
})
+4
View File
@@ -37,6 +37,10 @@ export default function TodoRow({ item, members, categories, today, isSelected,
// checkbox and its drag handle answer for themselves, hence the key handler
// only fires when the row itself has focus.
role="button"
// Opt out of the global :active press-scale: shrinking the row-wide button
// slides the checkbox out from under the pointer mid-click, so the click
// retargets onto the row and opens the detail pane instead (#2158).
data-no-press
tabIndex={0}
onClick={() => onSelect(isSelected ? null : item.id)}
onKeyDown={e => {