fix(data_editor): return true from onDelete so Delete clears the selection
VI
2d ago+188+188+012345678901234567890123456789-2-2-0123456789
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?
Description
Closes #7852
Glide calls onDelete synchronously and uses its return value: true deletes the selection, false cancels, and anything else is treated as the selection to delete. Reflex rendered on_delete as a normal event callback, which returned the result of addEvents (undefined). Glide then read that as a selection and threw TypeError: toDelete.rows is not iterable, so the cell kept its value even though the handler received the selection.
DataEditor._rendernow wrapsonDeleteso it queues the Reflex event and then returnstrue, letting Glide delete the selection as it does whenon_deleteis not bound.- The wrap happens at render time, after event-trigger memoization, so the
useCallbackdependencies of the handler are unchanged. The cost is one small arrow function per render of the grid. - A backend handler can't cancel the delete or pick a different selection, since it can't answer Glide synchronously. The issue lists that as out of scope.
- I checked the other Glide callbacks Reflex exposes as event handlers:
onDeleteis the only one whose return value Glide uses synchronously (onRowAppendedacceptsundefined).
Tests
- Unit test (
tests/units/components/datadisplay/test_dataeditor.py): runs the renderedonDeleteunder node and asserts it returnstrueand queues exactly the expected event with the selection. Fails onmain. - Playwright test (
tests/integration/tests_playwright/test_data_editor.py): uses the app from the issue, clicks the second row, presses Delete, and asserts the handler got the selection, the cell was cleared throughon_cell_edited, and no page error occurred. Passes in dev and prod; fails onmainwith theTypeError. uv run pytest tests/units --cov: 15223 passed, coverage 81.68%.ruff check,ruff format,pyright reflex testsand the pre-commit hooks pass. The biome hook could not install locally (npm git-dependency restriction); this PR has no JS/JSON changes.- News fragment added in
packages/reflex-components-dataeditor/news/.
AI-assisted: I used Claude Code to help write this change and reviewed and tested it myself.