-
Notifications
You must be signed in to change notification settings - Fork 99
[WIP] fix(DataGrid): Allow columns with empty titles to be used in DataGrid
#1948
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
Draft
ErdaradunGaztea
wants to merge
8
commits into
posit-dev:main
Choose a base branch
from
ErdaradunGaztea:datagrid-empty-column
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
846ef3a
fix: allow columns with empty names in DataGrid
ErdaradunGaztea 6f05721
test: columns with empty names in DataGrid
ErdaradunGaztea e38e21b
Merge branch 'main' into datagrid-empty-column
schloerke 0d5b955
Merge branch 'main' into datagrid-empty-column
ErdaradunGaztea a7bbb7b
fix: update test fixture name
ErdaradunGaztea 3f7302f
fix: lint
ErdaradunGaztea 39b9e1f
fix: lint
ErdaradunGaztea bd8ca0c
Merge branch 'main' into datagrid-empty-column
schloerke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
tests/playwright/shiny/bugs/1844-datagrid-empty-column/app.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pandas as pd | ||
|
||
from shiny import App, Inputs, reactive, render, ui | ||
|
||
app_ui = ui.page_fluid( | ||
ui.output_data_frame("df1"), | ||
) | ||
|
||
|
||
def server(input: Inputs): | ||
df = reactive.Value( | ||
pd.DataFrame( | ||
{ | ||
"": [1, 2], | ||
"A": [4, 5], | ||
" ": [7, 8], | ||
} | ||
) | ||
) | ||
|
||
@render.data_frame | ||
def df1(): | ||
return render.DataGrid(df()) | ||
|
||
|
||
app = App(app_ui, server) |
20 changes: 20 additions & 0 deletions
20
tests/playwright/shiny/bugs/1844-datagrid-empty-column/test_1844_datagrid_empty_column.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
from playwright.sync_api import Page | ||
|
||
from shiny.playwright import controller | ||
from shiny.run import ShinyAppProc | ||
|
||
|
||
def test_empty_column_name(page: Page, local_app: ShinyAppProc) -> None: | ||
page.goto(local_app.url) | ||
|
||
df = controller.OutputDataFrame(page, "df1") | ||
df.expect_nrow(2) | ||
df.expect_ncol(3) | ||
df.expect_column_labels(["", "A", " "]) | ||
|
||
df.expect_cell("1", row=0, col=0) | ||
df.expect_cell("2", row=1, col=0) | ||
df.expect_cell("4", row=0, col=1) | ||
df.expect_cell("8", row=1, col=2) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we move
initName
into the function as this will only hold true if theinitName
is" "
.If other column names can be expanded, then they could both resolve to the same
" "
string.However, if we know that
""
is the only one being expanded and there are no duplicate names, then this function is only called once... which is safe.Changing to something more specific...