-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix data editor regression when starting from empty column #13309
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
Fix data editor regression when starting from empty column #13309
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!
|
|
@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.
Pull request overview
This PR fixes a regression in the data editor where editing cells in empty (None-only) columns incorrectly wrapped scalar values in lists. For example, entering "42" would return [42] instead of 42.
Key Changes:
- Modified
_parse_value()to distinguish betweenLISTandEMPTYcolumn data kinds, preserving scalar values for empty columns - Added comprehensive unit tests for scalar value handling with empty columns
- Added E2E test to verify the end-to-end behavior with both cell editing and row addition
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/elements/widgets/data_editor.py |
Splits handling of LIST and EMPTY column kinds to preserve scalar values from the frontend |
lib/tests/streamlit/elements/data_editor_test.py |
Adds parameterized test cases for scalar values and dedicated test for empty column editing |
e2e_playwright/st_data_editor_config.py |
Adds test app with empty column data editor configuration |
e2e_playwright/st_data_editor_config_test.py |
Adds regression test for empty column editing behavior |
e2e_playwright/shared/dataframe_utils.py |
Adds edit_cell_value() helper function for E2E tests |
SummaryThis PR fixes a regression in the data editor where editing cells in columns that start with The fix is minimal and targeted: it separates the handling of Changed Files:
Code QualityCore Fix (data_editor.py)The fix is well-implemented: if column_data_kind == ColumnDataKind.EMPTY:
# For empty columns, preserve the value type from the frontend.
# If it's a list (e.g., from multiselect), return as list.
# If it's a scalar (e.g., from number input), return as scalar.
return list(value) if is_list_like(value) else value # ty: ignoreStrengths:
New Helper Utility (dataframe_utils.py)The def edit_cell_value(page: Page, value: str, *, wait_for_run: bool = True) -> None:
"""Edit the currently open cell by filling a value and pressing Enter.
This helper function fills a value in the currently open cell editor
and submits it by pressing Enter. The cell must already be open for editing
(e.g., via click_on_cell with double_click=True).
Parameters
----------
page : Page
The Playwright page.
value : str
The value to fill in the cell.
wait_for_run : bool
Whether to wait for the app to complete a run after submitting.
Defaults to True.
"""
cell_overlay = get_open_cell_overlay(page)
cell_overlay.locator(".gdg-input").fill(value)
page.keyboard.press("Enter")
if wait_for_run:
wait_for_app_run(page)
Test CoverageUnit Tests ✅The unit tests are comprehensive and well-structured:
# Scalar values should remain scalars, not be wrapped in lists
assert df.iat[0, 0] == 42
assert not isinstance(df.iat[0, 0], list)
assert df.iat[0, 1] == "hello"
assert not isinstance(df.iat[0, 1], list)
# List values should remain lists
assert df.iat[0, 2] == ["a", "b"]
assert isinstance(df.iat[0, 2], list)E2E Tests
|
Fixes a regression where starting with an empty column in data editor leads to the value being returned as list. - Closes #13305 - Added unit and 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.
Describe your changes
Fixes a regression where starting with an empty column in data editor leads to the value being returned as list.
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.