Skip to content

Conversation

@MatthewCollinsNZ
Copy link

Add Grid Selection Props and Event Handler to DataEditor
This PR adds comprehensive grid selection capabilities to the DataEditor component, allowing developers to track and control cell, row, and column selections.

New Props Added:

Selection Control:
range_select: Controls range selection modes ("none", "cell", "rect", "multi-cell", "multi-rect")
column_select: Already existed, allows column selections ("none", "single", "multi")
row_select: Controls row selection modes ("none", "single", "multi")

Selection Blending:
range_selection_blending: Controls how range selections coexist ("exclusive", "mixed")
column_selection_blending: Controls how column selections coexist ("exclusive", "mixed")
row_selection_blending: Controls how row selections coexist ("exclusive", "mixed")
Selection Behavior:

span_range_behavior: Controls how cell spans are handled in selections ("default", "allowPartial")

State Management:
grid_selection: Controlled state prop for the current selection (columns, rows, and current cell/range)
on_grid_selection_change: Event handler that fires when selection changes, passing the current GridSelection object

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

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 9, 2025

Greptile Overview

Greptile Summary

This PR adds comprehensive grid selection capabilities to the DataEditor component, enabling developers to track and control cell, row, and column selections through the Glide Data Grid library.

  • Added new selection control props: range_select, row_select, and selection blending options (range_selection_blending, column_selection_blending, row_selection_blending, span_range_behavior)
  • Added controlled grid_selection prop and on_grid_selection_change event handler for tracking selection state
  • Added JavaScript helper function reconstructGridSelection to properly reconstruct CompactSelection objects from Python dict representations when passing state back to the grid
  • Added CompactSelection import from glide-data-grid library to support the reconstruction logic

Confidence Score: 4/5

  • This PR is safe to merge - it adds new non-breaking functionality following established patterns in the codebase.
  • The implementation follows existing patterns for adding props, event handlers, and custom JavaScript code. The new add_custom_code method mirrors the approach used in other components like Plotly. The CompactSelection import is correctly added and used. Score of 4 rather than 5 because the JavaScript reconstruction logic relies on CompactSelection internal API structure which could change in future library versions.
  • No files require special attention - the changes are well-structured and follow existing patterns.

Important Files Changed

File Analysis

Filename Score Overview
reflex/components/datadisplay/dataeditor.py 4/5 Adds grid selection props and event handler with JavaScript reconstruction for CompactSelection objects. Implementation follows established patterns.

Sequence Diagram

sequenceDiagram
    participant User
    participant DataEditor
    participant State
    participant GlideDataGrid

    User->>DataEditor: Clicks/selects cells/rows/columns
    DataEditor->>GlideDataGrid: Selection event triggered
    GlideDataGrid->>DataEditor: on_grid_selection_change(GridSelection)
    DataEditor->>State: Updates grid_selection state variable
    State->>DataEditor: Re-render with new grid_selection
    DataEditor->>DataEditor: reconstructGridSelection(selection)
    Note right of DataEditor: Converts Python dict to<br/>CompactSelection objects
    DataEditor->>GlideDataGrid: Pass reconstructed GridSelection prop
    GlideDataGrid->>User: Display updated selection state
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

masenf
masenf previously approved these changes Dec 11, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 11, 2025

CodSpeed Performance Report

Merging #6028 will degrade performances by 3.5%

Comparing MatthewCollinsNZ:origin/MatthewCollinsNZ/dataeditorselectionprops (82b5f39) with main (bf49c88)

Summary

❌ 3 regressions
✅ 5 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_compile_page[_stateful_page] 10.4 ms 10.8 ms -3.27%
test_compile_stateful[_complicated_page] 583.3 µs 604.4 µs -3.5%
test_compile_page[_complicated_page] 88.3 ms 91.4 ms -3.42%

@adhami3310
Copy link
Member

can you provide an example of using grid_selection and on_grid_selection_change?

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