Repository navigation
CellMouseArgs.setActivePosition takes SetActivePositionOptions - #4258
Merged
Merged
Conversation
The `setActivePosition` passed to cell mouse event handlers now takes the same options object as `DataGridHandle.setActivePosition`, instead of a positional `enableEditor` boolean, so handlers can also pass `shouldFocus`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4258 +/- ##
=======================================
Coverage 99.27% 99.27%
=======================================
Files 44 44
Lines 2204 2204
Branches 965 964 -1
=======================================
Hits 2188 2188
Misses 16 16
🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
nstepien
marked this pull request as ready for review
October 31, 2026 23:52
nstepien
added a commit
that referenced
this pull request
Nov 1, 2026
Most columns aren't frozen, and start-frozen columns are more common than end-frozen ones, so every check of `column.frozen` now compares against `false` first, then against `'start'`. ### Changes - `getCellStyle`, `getCellClassname`, `getColSpan`, `collectColumns`, and the column sort check `false` first, then `'start'`. - `useViewportColumns` and the drag handle compare against `false` instead of checking truthiness. - `AGENTS.md` lists the rule under its conventions. The normalization of `rawColumn.frozen` in `useCalculatedColumns` stays as it is, since `undefined` is the most common value there. Rendered markup doesn't change: `renderToString` output is byte-identical for grids with unfrozen, start-frozen, and end-frozen columns, with and without `colSpan`. ### Performance The functions are faster, but whole renders don't change measurably. The change saves about 3 ns per cell, or 1.5 µs for an update of 600 cells, and all the code it touches is 0.2–0.5% of the CPU time of a mount or a scroll. Measured on the `vp pack` output with React's production build, on Windows, for 40 columns with 1 start-frozen column. Every measurement ran in a fresh process or page, with the order of the builds rotating between rounds: 10 rounds in Node, 8 in Chromium, 6 in Firefox, and 4 in WebKit. Differences are medians of the per-round differences, and a byte-identical copy of the build usually stayed within ±2%. These runs predate #4258, but this PR's built diff is identical to the measured one. Time per call, in hot loops: | Function | Node 26 | Chromium 156 | Firefox 157 | WebKit 27.2 | | ------------------ | -------------------: | -------------------: | -------------------: | -------------------: | | `getCellStyle` | 9.00 → 8.53 (−5.9%) | 9.83 → 8.71 (−11.7%) | 7.71 → 7.38 (−4.7%) | 4.12 → 3.74 (−9.6%) | | `getCellClassname` | 65.7 → 64.4 (−2.3%) | 32.3 → 30.7 (−4.6%) | 53.3 → 51.3 (−4.1%) | 17.8 → 17.1 (−4.5%) | In Node, `getColSpan` went from 3.68 to 2.76 ns (−25%), sorting 40 columns from 346 to 304 ns (−12%), and `useCalculatedColumns` from 3.57 to 3.48 µs (−2.5%). Mean render and commit time per update, in ms, without browser layout, for 10,000 rows: | Update | Chromium | Firefox | WebKit | | ------------------- | ------------------: | ------------------: | ------------------: | | Mount | 1.96 → 1.95 (−0.7%) | 5.39 → 5.31 (−1.6%) | 4.67 → 4.67 (+0.4%) | | Vertical scroll | 2.34 → 2.35 (+0.1%) | 5.96 → 5.93 (−0.2%) | 3.27 → 3.32 (−0.1%) | | Horizontal scroll | 1.70 → 1.69 (0.0%) | 4.06 → 4.07 (+0.4%) | 2.55 → 2.53 (+0.2%) | | New `columns` array | 0.75 → 0.75 (−0.4%) | 2.29 → 2.30 (+0.4%) | 0.84 → 0.87 (+4.1%) | In Node, `renderToString` of 100 rows took 5.37 ms before and 5.40 ms after (+1.2%), also within noise. There's one exception. In WebKit on Windows, a new `columns` array renders about 0.03 ms slower with these columns: +6.3%, +4.1%, and +3.9% in three separate runs of 4, 12, and 15 rounds. With 2 start-frozen and 2 end-frozen columns, it's 1–5% faster instead. The `getCellStyle` and `getCellClassname` changes each reproduce the slowdown, and a build with only the other changes doesn't. The cause is unknown: it's about 50 ns per cell, more than those two functions cost in total, so it's an indirect effect. It only applies when `columns` changes, and Safari wasn't tested. `vp run ci` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
setActivePositionpassed toonCellMouseDown,onCellClick,onCellDoubleClick, andonCellContextMenunow takes the sameSetActivePositionOptionsobject asDataGridHandle.setActivePositionandActiveCellKeyDownArgs.setActivePosition, instead of a positionalenableEditorboolean. The threesetActivePositionAPIs are consistent,args.setActivePosition({ enableEditor: true })says what it does, and mouse handlers can now passshouldFocus, e.g., a handler that callsevent.preventDefault()onmousedownto keep the browser from selecting text can still activate and focus the cell.Breaking change
function onCellClick(args: CellMouseArgs<Row>, event: CellMouseEvent) { - args.setActivePosition(true); + args.setActivePosition({ enableEditor: true }); }Affects
onCellMouseDown,onCellClick,onCellDoubleClick, andonCellContextMenuhandlers that callargs.setActivePosition. It takes the sameSetActivePositionOptionsasDataGridHandle.setActivePosition, soshouldFocusis available too.Changes
CellMouseArgs.setActivePositionis(options?: SetActivePositionOptions) => void. Its JSDoc now says it activates the cell, which it always did, rather than "focus", which it only does withshouldFocus.Cellforwards the options unchanged to the grid'ssetActivePosition; the double-click default passes{ enableEditor: true }, and the mousedown default passes no options, as before.onCellMouseDowndocs mention that a handler that prevents the grid default can activate and focus the cell withargs.setActivePosition({ shouldFocus: true }). The README examples, theCellMouseArgsdeclaration in the README, and the All Features demo use the new signature.Verification
vp run cipasses, except for Firefox click timeouts and focus failures in 12 test files under load from other sessions' browser tests; those 12 files pass when rerun alone in Firefox. A new test inevents.test.tsxcallsevent.preventDefault(),event.preventGridDefault(), andargs.setActivePosition({ shouldFocus: true })fromonCellMouseDown, and checks that the cell is active and focused; it fails withoutshouldFocus. TheonCellClickeditor test uses{ enableEditor: true }. The packedlib/index.d.tswas type-checked from a consumer file with and withoutexactOptionalPropertyTypes, including a@ts-expect-erroron the old boolean argument.🤖 Generated with Claude Code