Skip to content

fix(DEV-883): guard against header/corner selection in beforeKeyDown demo#12267

Merged
qunabu merged 4 commits intodevelopfrom
feature/DEV-883_Issues-with-beforeKeyDown-callback-demo
Apr 10, 2026
Merged

fix(DEV-883): guard against header/corner selection in beforeKeyDown demo#12267
qunabu merged 4 commits intodevelopfrom
feature/DEV-883_Issues-with-beforeKeyDown-callback-demo

Conversation

@qunabu
Copy link
Copy Markdown
Contributor

@qunabu qunabu commented Apr 2, 2026

Summary

Fixes issues with the "The beforeKeyDown callback" paragraph demo on the Events and hooks guide page.

Root cause: When a column header is selected, hot.getSelected() returns a selection with row index -1. The demo's beforeKeyDown handler passed this directly to hot.spliceCol(col, -1, amount), which triggered an internal assertion error: "Assertion failed: Expecting an unsigned number".

Changes:

  • Added a guard if (selection[0] < 0) return to skip header and corner selections in all framework examples (JS, TS, React JSX/TSX, Angular)
  • Added null-guard for hot.getSelected() in the plain JS/TS examples (React and Angular already had this)

Fixes: https://app.clickup.com/t/86c954frd (DEV-883)

[skip changelog]

Test plan

  • Go to the Events and hooks demo page
  • Click the column header (A, B, C, ...) to select an entire column
  • Press Delete or Backspace — no console error should appear
  • Click a single data cell (e.g. B2), press Delete — data is removed correctly (shifts column up)
  • Verify same behavior in React, Angular framework variants of the example

https://claude.ai/code/session_01CquCfX7q6sQp19ujjDqcUD


Note

Low Risk
Low risk doc-example change that only adds defensive guards around selection handling to avoid runtime assertions when headers are selected.

Overview
Fixes the Events and hooks beforeKeyDown documentation demos to avoid errors when a user selects a row/column header or the corner.

Across Angular, React (JSX/TSX), and vanilla JS/TS examples, the handler now bails out when getSelected() is null/undefined or when the selection contains negative row/column indices, preventing invalid spliceCol() calls.

Reviewed by Cursor Bugbot for commit f829c72. Bugbot is set up for automated code reviews on this repo. Configure here.

…demo

When a column header is selected, `hot.getSelected()` returns a selection
with row index `-1`. Calling `hot.spliceCol(col, -1, amount)` triggers an
assertion error ("Expecting an unsigned number") in the internal LazyFactoryMap.

Also add a null-guard for `hot.getSelected()` in the JS/TS plain examples,
matching the defensive pattern already present in React and Angular versions.

Fixes: https://app.clickup.com/t/86c954frd (DEV-883)

https://claude.ai/code/session_01CquCfX7q6sQp19ujjDqcUD
@qunabu
Copy link
Copy Markdown
Contributor Author

qunabu commented Apr 2, 2026

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 2, 2026

More templates

npm i https://pkg.pr.new/handsontable@12267
npm i https://pkg.pr.new/@handsontable/react-wrapper@12267
npm i https://pkg.pr.new/@handsontable/vue3@12267
npm i https://pkg.pr.new/@handsontable/angular-wrapper@12267

commit: f829c72

The docs example generator (tsc + ESLint/Prettier) does not require blank
lines after single-line `if` guards (no block body). Remove the two extra
blank lines from example2.js and example2.jsx so the committed files match
what `docs:code-examples:generate-all-js` produces, fixing the Docs Examples
CI check.

https://claude.ai/code/session_01CquCfX7q6sQp19ujjDqcUD
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

✅ Preview documentation is is available now
Current staging version of documentation is available at: https://dev-handsontable-feature-dev-883-issu.netlify.app/docs

@qunabu qunabu requested a review from adrianspdev April 2, 2026 20:51
@qunabu qunabu self-assigned this Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Performance tests results

Artifacts: performance-tests-output (open the workflow run, then download performance-tests-output).


Metric latest current % change Value change
Total (ms) 15462 15191 -1.8% -271
System (ms) 506 472 -6.7% -34
Scripting (ms) 4998 2976 -40.5% -2022
Rendering (ms) 2933 2456 -16.3% -477
Loading (ms) 0 0 0% 0
Painting (ms) 536 479 -10.6% -57
Experience (ms)
Idle (ms) 6488 8807 +35.7% +2319
Min JS heap (kb) 924 kb 924 kb +0.0% 0
Max JS heap (Mb) 39.5 Mb 53.4 Mb +35.0% +13.8 Mb
Min Documents (count) 2 2 +0.0% 0
Max Documents (count) 4 4 +0.0% 0
Min Nodes (count) 20 20 +0.0% 0
Max Nodes (count) 150741 150921 +0.1% +180
Min Listeners (count) 0 0 0% 0
Max Listeners (count) 153 156 +2.0% +3

@qunabu qunabu marked this pull request as ready for review April 7, 2026 13:07
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e9d0ec7. Configure here.

Comment thread docs/content/guides/getting-started/events-and-hooks/javascript/example2.js Outdated
Also check selection[1] < 0 to prevent spliceCol(-1,...) when a
row header is clicked (DEV-883).

https://claude.ai/code/session_01CquCfX7q6sQp19ujjDqcUD
@qunabu qunabu merged commit e188e42 into develop Apr 10, 2026
37 of 38 checks passed
@qunabu qunabu deleted the feature/DEV-883_Issues-with-beforeKeyDown-callback-demo branch April 10, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants