-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug(input_text_area): Auto resized text areas resize on visibility ch…
…ange (#1569) Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
- Loading branch information
Showing
5 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
26 changes: 26 additions & 0 deletions
26
tests/playwright/shiny/inputs/input_text_area/autoresize/app.py
This file contains 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 @@ | ||
from shiny.express import render, ui | ||
|
||
with ui.navset_card_tab(id="tab"): | ||
|
||
with ui.nav_panel("Tab 1"): | ||
"Tab 1 content" | ||
with ui.nav_panel("Text Area"): | ||
ui.input_text_area( | ||
id="test_text_area", | ||
label="A text area input", | ||
autoresize=True, | ||
value="a\nb\nc\nd\ne", | ||
) | ||
|
||
ui.input_text_area( | ||
id="test_text_area2", | ||
label="A second text area input", | ||
autoresize=True, | ||
value="a\nb\nc\nd\ne", | ||
rows=4, | ||
) | ||
|
||
|
||
@render.code | ||
def text(): | ||
return "Loaded" |
47 changes: 47 additions & 0 deletions
47
tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py
This file contains 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,47 @@ | ||
from playwright.sync_api import Page | ||
|
||
from shiny.playwright import controller | ||
from shiny.playwright.expect import expect_to_have_style | ||
from shiny.run import ShinyAppProc | ||
|
||
|
||
def test_accordion(page: Page, local_app: ShinyAppProc, is_webkit: bool) -> None: | ||
page.goto(local_app.url) | ||
|
||
text = controller.OutputCode(page, "text") | ||
tab = controller.NavsetTab(page, "tab") | ||
|
||
test_text_area = controller.InputTextArea(page, "test_text_area") | ||
test_text_area_w_rows = controller.InputTextArea(page, "test_text_area2") | ||
|
||
text.expect_value("Loaded") | ||
|
||
# Make sure the `rows` is respected | ||
test_text_area_w_rows.expect_rows("4") | ||
# Make sure the placeholder row value of `1` is set | ||
test_text_area.expect_rows("1") | ||
|
||
tab.set("Text Area") | ||
|
||
test_text_area.expect_autoresize(True) | ||
test_text_area.expect_value("a\nb\nc\nd\ne") | ||
|
||
if is_webkit: | ||
# Skip the rest of the test for webkit. | ||
# Heights are not consistent with chrome and firefox | ||
return | ||
expect_to_have_style(test_text_area.loc, "height", "125px") | ||
expect_to_have_style(test_text_area_w_rows.loc, "height", "125px") | ||
|
||
# Make sure the `rows` is consistent | ||
test_text_area.expect_rows("1") | ||
test_text_area_w_rows.expect_rows("4") | ||
|
||
# Reset the text area to a single row and make sure the area shrink to appropriate size | ||
test_text_area.set("single row") | ||
test_text_area_w_rows.set("single row") | ||
|
||
# 1 row | ||
expect_to_have_style(test_text_area.loc, "height", "35px") | ||
# 4 rows | ||
expect_to_have_style(test_text_area_w_rows.loc, "height", "102px") |