pierrejeambrun opened a new pull request, #68229:
URL: https://github.com/apache/airflow/pull/68229

   Clicking a row checkbox in the Task Instances / Dag Runs / Variables / 
Connections tables had a visible delay (~500ms) before the checked state 
appeared.
   
   ### Cause
   
   Each click went through `setSelectedRows(new Map(...))` in 
`useRowSelection`. The page then re-rendered and called e.g. 
`taskInstanceColumns({…selectedRows, onRowSelect, allRowsSelected, 
onSelectAll})`, which returned a fresh columns array on every click. TanStack 
Table treated the new column reference as a fresh definition and re-rendered 
every cell — including the heavy ones (`Time`, `RouterLink`, `StateBadge`, 
`DagVersion`, plus the per-row action buttons). With 30–50 rows × ~12 cells 
that easily reached hundreds of milliseconds before React painted the new 
checked state.
   
   Secondary issue: `selectedRows.get(key)` returned `boolean | undefined`, 
which made the Chakra checkbox flip between uncontrolled (when undefined) and 
controlled (when boolean) modes across renders.
   
   ### Fix
   
   - Add a `SelectionContext` (provided by a new `SelectionProvider`) and two 
dedicated components in `useRowSelection.tsx`: `SelectionRowCheckbox` and 
`SelectionHeaderCheckbox`. They read selection state from context instead of 
receiving it via the columns args.
   - Update `taskInstanceColumns` / `runColumns` / `getColumns` in the four 
pages to drop the selection-state args and render the new components in the 
`select` column.
   - Wrap each page's children with `<SelectionProvider …>`.
   
   Because the columns array no longer depends on `selectedRows`, it's stable 
across clicks. Only the ~50 lightweight checkbox components re-render on each 
selection change instead of the whole grid.
   
   Also switch the `checked` prop from `selectedRows.get(key)` (`boolean | 
undefined`) to `selectedRows.has(key)` (`boolean`) so the checkbox stays in 
controlled mode.
   
   Applied to all four tables that use multi-selection: TaskInstances, DagRuns, 
Variables, Connections.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.7)
   
   Generated-by: Claude Code (Opus 4.7) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to