Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Dec 5, 2025

Describe your changes

Adds support for setting num_rows to add and delete to configure that only adding new rows or deleting rows is allowed, but not both (as with dynamic).

GitHub Issue Link (if applicable)

Testing Plan

  • Added e2e tests.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Dec 5, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13228/streamlit-1.52.1-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13228.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Dec 5, 2025
@lukasmasuch lukasmasuch marked this pull request as ready for review December 5, 2025 09:54
@lukasmasuch lukasmasuch requested a review from a team as a code owner December 5, 2025 09:54
Copilot AI review requested due to automatic review settings December 5, 2025 09:54
Copy link
Contributor

Copilot AI left a 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_ONLY and DELETE_ONLY protobuf enum values for new editing modes
  • Updated Python backend to accept "add" and "delete" as num_rows parameter 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

Copy link

@cursor cursor bot left a 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.

@lukasmasuch
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a 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(
Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated 👍

@lukasmasuch lukasmasuch enabled auto-merge (squash) December 10, 2025 12:34
@github-actions
Copy link
Contributor

📈 Frontend coverage change detected

The frontend unit test (vitest) coverage has increased by 0.0500%

  • Current PR: 85.9300% (12446 lines, 1750 missed)
  • Latest develop: 85.8800% (12445 lines, 1757 missed)

🎉 Great job on improving test coverage!

📊 View detailed coverage comparison

@lukasmasuch lukasmasuch merged commit 4b85c3f into develop Dec 10, 2025
43 checks passed
@lukasmasuch lukasmasuch deleted the Allow-only-adding-or-deleting-rows-for-`st.data_editor` branch December 10, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data_editor: num_rows - option to allow for only adding or only deleting rows

3 participants