fix(data_editor): return true from onDelete so Delete clears the selection

VI
2d ago
+188-2

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._render now wraps onDelete so it queues the Reflex event and then returns true, letting Glide delete the selection as it does when on_delete is not bound.
  • The wrap happens at render time, after event-trigger memoization, so the useCallback dependencies 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: onDelete is the only one whose return value Glide uses synchronously (onRowAppended accepts undefined).

Tests

  • Unit test (tests/units/components/datadisplay/test_dataeditor.py): runs the rendered onDelete under node and asserts it returns true and queues exactly the expected event with the selection. Fails on main.
  • 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 through on_cell_edited, and no page error occurred. Passes in dev and prod; fails on main with the TypeError.
  • uv run pytest tests/units --cov: 15223 passed, coverage 81.68%.
  • ruff check, ruff format, pyright reflex tests and 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.