Skip to content

Commit

Permalink
bug(edit: data frame): If the cell's value is null, edit value shou…
Browse files Browse the repository at this point in the history
…ld be `""` (#1551)
  • Loading branch information
schloerke authored Jul 18, 2024
1 parent 5112115 commit 57afa2b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
5 changes: 2 additions & 3 deletions js/data-frame/cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ const isShinyHtml = (x: any): x is CellHtmlValue => {
};
type CellValue = string | CellHtmlValue | null;
const getCellValueText = (cellValue: CellValue) => {
if (isShinyHtml(cellValue)) {
return cellValue.obj.html;
}
if (isShinyHtml(cellValue)) return cellValue.obj.html;
if (cellValue === null) return "";
return cellValue as string;
};

Expand Down
2 changes: 1 addition & 1 deletion shiny/www/py-shiny/data-frame/data-frame.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions shiny/www/py-shiny/data-frame/data-frame.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@


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

page.goto(local_app.url)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest
from playwright.sync_api import Page
from utils.deploy_utils import skip_if_not_chrome

from shiny.playwright import controller
from shiny.run import ShinyAppProc


@skip_if_not_chrome
@pytest.mark.parametrize("df_type", ["pandas", "polars"])
def test_edit_cell_content_is_not_null(
page: Page, local_app: ShinyAppProc, df_type: str
) -> None:
page.goto(local_app.url)

data_frame = controller.OutputDataFrame(page, f"{df_type}_df")

tab = controller.NavsetCardUnderline(page, "tab")
tab.set(df_type)

data_frame.expect_cell("", row=0, col=14)
empty_cell = data_frame.cell_locator(row=0, col=14)
empty_cell.dblclick()
textarea = empty_cell.locator("textarea")
textarea.wait_for()
cur_value = textarea.input_value()
assert cur_value == ""

0 comments on commit 57afa2b

Please sign in to comment.