Allow only adding or deleting rows in st.data_editor#13228
Allow only adding or deleting rows in st.data_editor#13228lukasmasuch merged 10 commits intodevelopfrom
st.data_editor#13228Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for num_rows="add" and num_rows="delete" to st.data_editor, allowing users to restrict row operations to only adding or only deleting rows, in addition to the existing "fixed" (no operations) and "dynamic" (both operations) modes.
Key changes:
- Added
ADD_ONLYandDELETE_ONLYprotobuf enum values for new editing modes - Updated Python backend to accept "add" and "delete" as
num_rowsparameter values - Modified frontend logic to conditionally enable add/delete UI based on editing mode
- Added comprehensive unit and E2E tests for the new functionality
Reviewed changes
Copilot reviewed 8 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
proto/streamlit/proto/Arrow.proto |
Added ADD_ONLY and DELETE_ONLY enum values to EditingMode |
lib/streamlit/elements/widgets/data_editor.py |
Updated type annotations and mapping logic for new num_rows values; refined warning messages |
lib/tests/streamlit/elements/data_editor_test.py |
Added unit tests for add/delete modes and updated existing warning tests |
frontend/lib/src/components/widgets/DataFrame/DataFrame.tsx |
Refactored to use canAddRows/canDeleteRows flags based on editing mode |
frontend/lib/src/components/widgets/DataFrame/hooks/useTableSizer.ts |
Updated trailing row logic to include ADD_ONLY mode |
frontend/lib/src/components/widgets/DataFrame/DataFrame.test.tsx |
Added tests verifying correct behavior for each editing mode |
e2e_playwright/st_data_editor_config.py |
Added test data editors for add, delete, and dynamic modes with unique keys |
e2e_playwright/st_data_editor_config_test.py |
Added E2E tests verifying add/delete button behavior and introduced _get_editor helper |
e2e_playwright/__snapshots__/linux/.../*.png |
Added visual regression test snapshots for new modes across browsers |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
@cursor review |
| @@ -63,7 +64,8 @@ const LOG = getLogger("useDataEditor") | |||
| */ | |||
| function useDataEditor( | |||
There was a problem hiding this comment.
suggestion (non-blocking): There are a lot of positional params to this function, which can make usage harder. Consider refactoring this to use an object for its params.
| return useDataEditor( | ||
| MOCK_COLUMNS, | ||
| false, | ||
| true, // canAddRows |
There was a problem hiding this comment.
note: In tandem with my comment in its source, using an object for params would negate the need to add comments to these positional boolean fields.
…g-or-deleting-rows-for-`st.data_editor`
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0500%
🎉 Great job on improving test coverage! |
Describe your changes
Adds support for setting
num_rowstoaddanddeleteto configure that only adding new rows or deleting rows is allowed, but not both (as withdynamic).GitHub Issue Link (if applicable)
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.