Skip to content

Commit 57afa2b

Browse files
authored
bug(edit: data frame): If the cell's value is null, edit value should be "" (posit-dev#1551)
1 parent 5112115 commit 57afa2b

File tree

10 files changed

+33
-9
lines changed

10 files changed

+33
-9
lines changed

js/data-frame/cell.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ const isShinyHtml = (x: any): x is CellHtmlValue => {
6262
};
6363
type CellValue = string | CellHtmlValue | null;
6464
const getCellValueText = (cellValue: CellValue) => {
65-
if (isShinyHtml(cellValue)) {
66-
return cellValue.obj.html;
67-
}
65+
if (isShinyHtml(cellValue)) return cellValue.obj.html;
66+
if (cellValue === null) return "";
6867
return cellValue as string;
6968
};
7069

shiny/www/py-shiny/data-frame/data-frame.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/py-shiny/data-frame/data-frame.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88

99
@pytest.mark.parametrize("tab_name", ["pandas", "polars"])
10-
def test_dataframe_organization_methods(
11-
page: Page, local_app: ShinyAppProc, tab_name: str
12-
) -> None:
10+
def test_dataframe_methods(page: Page, local_app: ShinyAppProc, tab_name: str) -> None:
1311

1412
page.goto(local_app.url)
1513

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
from playwright.sync_api import Page
3+
from utils.deploy_utils import skip_if_not_chrome
4+
5+
from shiny.playwright import controller
6+
from shiny.run import ShinyAppProc
7+
8+
9+
@skip_if_not_chrome
10+
@pytest.mark.parametrize("df_type", ["pandas", "polars"])
11+
def test_edit_cell_content_is_not_null(
12+
page: Page, local_app: ShinyAppProc, df_type: str
13+
) -> None:
14+
page.goto(local_app.url)
15+
16+
data_frame = controller.OutputDataFrame(page, f"{df_type}_df")
17+
18+
tab = controller.NavsetCardUnderline(page, "tab")
19+
tab.set(df_type)
20+
21+
data_frame.expect_cell("", row=0, col=14)
22+
empty_cell = data_frame.cell_locator(row=0, col=14)
23+
empty_cell.dblclick()
24+
textarea = empty_cell.locator("textarea")
25+
textarea.wait_for()
26+
cur_value = textarea.input_value()
27+
assert cur_value == ""

0 commit comments

Comments
 (0)