-
Notifications
You must be signed in to change notification settings - Fork 4k
Allow only adding or deleting rows in st.data_editor
#13228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow only adding or deleting rows in st.data_editor
#13228
Conversation
✅ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no bugs!
| * | ||
| * @returns Glide-data-grid compatible functions for editing capabilities. | ||
| */ | ||
| function useDataEditor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 👍
| return useDataEditor( | ||
| MOCK_COLUMNS, | ||
| false, | ||
| true, // canAddRows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 👍
…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.