From b904ea27a3affab3f722e1c69d37214ba0c4475a Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 10:44:12 -0400 Subject: [PATCH 1/9] Move existing test --- tests/playwright/shiny/components/accordion/{ => basic}/app.py | 0 .../shiny/components/accordion/{ => basic}/test_accordion.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/playwright/shiny/components/accordion/{ => basic}/app.py (100%) rename tests/playwright/shiny/components/accordion/{ => basic}/test_accordion.py (100%) diff --git a/tests/playwright/shiny/components/accordion/app.py b/tests/playwright/shiny/components/accordion/basic/app.py similarity index 100% rename from tests/playwright/shiny/components/accordion/app.py rename to tests/playwright/shiny/components/accordion/basic/app.py diff --git a/tests/playwright/shiny/components/accordion/test_accordion.py b/tests/playwright/shiny/components/accordion/basic/test_accordion.py similarity index 100% rename from tests/playwright/shiny/components/accordion/test_accordion.py rename to tests/playwright/shiny/components/accordion/basic/test_accordion.py From c64ecf9ec388e97ff11712f9ce4f59e573b998e6 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 10:44:45 -0400 Subject: [PATCH 2/9] Add support for text area auto resize who is hidden --- js/text-area/textarea-autoresize.ts | 38 +++++++++++++++++-- shiny/ui/_input_text.py | 5 ++- .../py-shiny/text-area/textarea-autoresize.js | 21 +++++++++- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/js/text-area/textarea-autoresize.ts b/js/text-area/textarea-autoresize.ts index 2ba512349..618ac6343 100644 --- a/js/text-area/textarea-autoresize.ts +++ b/js/text-area/textarea-autoresize.ts @@ -19,9 +19,41 @@ function onDelegatedEvent( } function update_height(target: HTMLTextAreaElement) { - // Automatically resize the textarea to fit its content. - target.style.height = "auto"; - target.style.height = target.scrollHeight + "px"; + if (target.scrollHeight > 0) { + // Automatically resize the textarea to fit its content. + target.style.height = "auto"; + target.style.height = target.scrollHeight + "px"; + } else { + // The textarea is not visible on the page, therefore it has a 0 scroll height. + + // If `.getAttribute("rows")` is set to 0 (as `target.rows` is always > 0 and + // invalid values use the default value of `2`), then we can wait for the textarea + // to become visible and call `update_height` again as the scroll height should not + // be 0. + // + // Note: `rows` is only set to `0` from the python code when the textarea is + // autoresized and no `rows` value is given. + const targetRows = target.getAttribute("rows"); + if (targetRows == "0") { + // Create an observer to watch for the textarea becoming visible + const observer = new IntersectionObserver((entries, observer) => { + entries.forEach((entry) => { + // If the entry is visible (even if it's just a single pixel) + if (entry.intersectionRatio > 0) { + // Stop observing the target + observer.unobserve(entry.target); + + // Reset rows to `1` so that the textarea shrinks when content is removed. + // (Otherwise the `0` value placeholder actually represents the default value of `2`) + const entryTarget = entry.target as HTMLTextAreaElement; + entryTarget.rows = 1; + update_height(entryTarget); + } + }); + }); + observer.observe(target); + } + } } // Update on change diff --git a/shiny/ui/_input_text.py b/shiny/ui/_input_text.py index 1f5fc09ab..1e6c51715 100644 --- a/shiny/ui/_input_text.py +++ b/shiny/ui/_input_text.py @@ -163,7 +163,10 @@ def input_text_area( if autoresize: classes.append("textarea-autoresize") if rows is None: - rows = 1 + # Use a placeholder of `_auto_` (an invalid value) to signal that the textarea + # should autoresized on load + # rows = "_auto_" + rows = 0 resolved_id = resolve_id(id) area = tags.textarea( diff --git a/shiny/www/py-shiny/text-area/textarea-autoresize.js b/shiny/www/py-shiny/text-area/textarea-autoresize.js index 944ac8b09..99c2ad8c3 100644 --- a/shiny/www/py-shiny/text-area/textarea-autoresize.js +++ b/shiny/www/py-shiny/text-area/textarea-autoresize.js @@ -8,8 +8,25 @@ function onDelegatedEvent(eventName, selector, callback) { }); } function update_height(target) { - target.style.height = "auto"; - target.style.height = target.scrollHeight + "px"; + if (target.scrollHeight > 0) { + target.style.height = "auto"; + target.style.height = target.scrollHeight + "px"; + } else { + const targetRows = target.getAttribute("rows"); + if (targetRows == "0") { + const observer = new IntersectionObserver((entries, observer2) => { + entries.forEach((entry) => { + if (entry.intersectionRatio > 0) { + observer2.unobserve(entry.target); + const entryTarget = entry.target; + entryTarget.rows = 1; + update_height(entryTarget); + } + }); + }); + observer.observe(target); + } + } } onDelegatedEvent( "input", From eb39acdc97ed8f86b2ce0898e4cb55a5a34f3c53 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 10:52:33 -0400 Subject: [PATCH 3/9] Add test --- .../components/accordion/autoresize/app.py | 34 ++++++++++++ .../autoresize/test_accordion_autoresize.py | 52 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/playwright/shiny/components/accordion/autoresize/app.py create mode 100644 tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py diff --git a/tests/playwright/shiny/components/accordion/autoresize/app.py b/tests/playwright/shiny/components/accordion/autoresize/app.py new file mode 100644 index 000000000..f5ffc036c --- /dev/null +++ b/tests/playwright/shiny/components/accordion/autoresize/app.py @@ -0,0 +1,34 @@ +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="How can this UI code be tweaked\n" + "such that this multiline string\n" + "makes the Text Area Input object\n" + "resize itself event though it lives\n" + "inside an Accordion element?", + ) + + ui.input_text_area( + id="test_text_area2", + label="A second text area input", + autoresize=True, + value="How can this UI code be tweaked\n" + "such that this multiline string\n" + "makes the Text Area Input object\n" + "resize itself event though it lives\n" + "inside an Accordion element?", + rows=4, + ) + + +@render.code +def text(): + return "Loaded" diff --git a/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py b/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py new file mode 100644 index 000000000..5327e3b4a --- /dev/null +++ b/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py @@ -0,0 +1,52 @@ +from playwright.sync_api import Page + +from shiny.playwright import controller +from shiny.playwright.expect import expect_not_to_have_style, expect_to_have_style +from shiny.run import ShinyAppProc + + +def test_accordion(page: Page, local_app: ShinyAppProc) -> 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 `0` is set + test_text_area.expect_rows("0") + + tab.set("Text Area") + + textareatext = ( + "How can this UI code be tweaked\n" + "such that this multiline string\n" + "makes the Text Area Input object\n" + "resize itself event though it lives\n" + "inside an Accordion element?" + ) + + test_text_area.expect_autoresize(True) + test_text_area.expect_value(textareatext) + + expect_to_have_style(test_text_area.loc, "height", "125px") + expect_not_to_have_style(test_text_area_w_rows.loc, "height") + + # Make sure the placeholder row value of `1` is set + test_text_area.expect_rows("1") + # Make sure the `rows` is respected + 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") From 542731d83be376ffb539786df6e49d45bd5115e6 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 12:09:58 -0400 Subject: [PATCH 4/9] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ada97cb4..4ef02f668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Require shinyswatch >= 0.7.0 and updated examples accordingly. (#1558) +* Fixed bug where an auto resized input text area was not initially auto resized if the element was hidden from view (e.g. in a closed accordion or a hidden tab). (#1560) + ### Bug fixes ### Deprecations From 8361d1f22fea5dcb7c44a1b428b794fc48890b36 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 13:34:18 -0400 Subject: [PATCH 5/9] Code feedback from @cpsievert --- js/text-area/textarea-autoresize.ts | 50 ++++++++----------- shiny/ui/_input_text.py | 5 +- .../py-shiny/text-area/textarea-autoresize.js | 25 ++++------ .../components/accordion/autoresize/app.py | 12 +---- .../autoresize/test_accordion_autoresize.py | 21 +++----- 5 files changed, 40 insertions(+), 73 deletions(-) diff --git a/js/text-area/textarea-autoresize.ts b/js/text-area/textarea-autoresize.ts index 618ac6343..f0bcb2ca4 100644 --- a/js/text-area/textarea-autoresize.ts +++ b/js/text-area/textarea-autoresize.ts @@ -23,37 +23,29 @@ function update_height(target: HTMLTextAreaElement) { // Automatically resize the textarea to fit its content. target.style.height = "auto"; target.style.height = target.scrollHeight + "px"; - } else { - // The textarea is not visible on the page, therefore it has a 0 scroll height. + return; + } - // If `.getAttribute("rows")` is set to 0 (as `target.rows` is always > 0 and - // invalid values use the default value of `2`), then we can wait for the textarea - // to become visible and call `update_height` again as the scroll height should not - // be 0. - // - // Note: `rows` is only set to `0` from the python code when the textarea is - // autoresized and no `rows` value is given. - const targetRows = target.getAttribute("rows"); - if (targetRows == "0") { - // Create an observer to watch for the textarea becoming visible - const observer = new IntersectionObserver((entries, observer) => { - entries.forEach((entry) => { - // If the entry is visible (even if it's just a single pixel) - if (entry.intersectionRatio > 0) { - // Stop observing the target - observer.unobserve(entry.target); + // The textarea is not visible on the page, therefore it has a 0 scroll height. - // Reset rows to `1` so that the textarea shrinks when content is removed. - // (Otherwise the `0` value placeholder actually represents the default value of `2`) - const entryTarget = entry.target as HTMLTextAreaElement; - entryTarget.rows = 1; - update_height(entryTarget); - } - }); - }); - observer.observe(target); - } - } + // If we should autoresize the text area height, then we can wait for the textarea to + // become visible and call `update_height` again. Hopefully the scroll height is no + // longer 0 + + // Create an observer to watch for the textarea becoming visible + const observer = new IntersectionObserver((entries, observer) => { + entries.forEach((entry) => { + // If the entry is visible (even if it's just a single pixel) + if (entry.intersectionRatio > 0) { + // Stop observing the target + observer.unobserve(entry.target); + + // Update the height of the textarea + update_height(entry.target as HTMLTextAreaElement); + } + }); + }); + observer.observe(target); } // Update on change diff --git a/shiny/ui/_input_text.py b/shiny/ui/_input_text.py index 1e6c51715..1f5fc09ab 100644 --- a/shiny/ui/_input_text.py +++ b/shiny/ui/_input_text.py @@ -163,10 +163,7 @@ def input_text_area( if autoresize: classes.append("textarea-autoresize") if rows is None: - # Use a placeholder of `_auto_` (an invalid value) to signal that the textarea - # should autoresized on load - # rows = "_auto_" - rows = 0 + rows = 1 resolved_id = resolve_id(id) area = tags.textarea( diff --git a/shiny/www/py-shiny/text-area/textarea-autoresize.js b/shiny/www/py-shiny/text-area/textarea-autoresize.js index 99c2ad8c3..7cd9354c0 100644 --- a/shiny/www/py-shiny/text-area/textarea-autoresize.js +++ b/shiny/www/py-shiny/text-area/textarea-autoresize.js @@ -11,22 +11,17 @@ function update_height(target) { if (target.scrollHeight > 0) { target.style.height = "auto"; target.style.height = target.scrollHeight + "px"; - } else { - const targetRows = target.getAttribute("rows"); - if (targetRows == "0") { - const observer = new IntersectionObserver((entries, observer2) => { - entries.forEach((entry) => { - if (entry.intersectionRatio > 0) { - observer2.unobserve(entry.target); - const entryTarget = entry.target; - entryTarget.rows = 1; - update_height(entryTarget); - } - }); - }); - observer.observe(target); - } + return; } + const observer = new IntersectionObserver((entries, observer2) => { + entries.forEach((entry) => { + if (entry.intersectionRatio > 0) { + observer2.unobserve(entry.target); + update_height(entry.target); + } + }); + }); + observer.observe(target); } onDelegatedEvent( "input", diff --git a/tests/playwright/shiny/components/accordion/autoresize/app.py b/tests/playwright/shiny/components/accordion/autoresize/app.py index f5ffc036c..b23116334 100644 --- a/tests/playwright/shiny/components/accordion/autoresize/app.py +++ b/tests/playwright/shiny/components/accordion/autoresize/app.py @@ -9,22 +9,14 @@ id="test_text_area", label="A text area input", autoresize=True, - value="How can this UI code be tweaked\n" - "such that this multiline string\n" - "makes the Text Area Input object\n" - "resize itself event though it lives\n" - "inside an Accordion element?", + value="a\nb\nc\nd\ne", ) ui.input_text_area( id="test_text_area2", label="A second text area input", autoresize=True, - value="How can this UI code be tweaked\n" - "such that this multiline string\n" - "makes the Text Area Input object\n" - "resize itself event though it lives\n" - "inside an Accordion element?", + value="a\nb\nc\nd\ne", rows=4, ) diff --git a/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py b/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py index 5327e3b4a..37d63d76a 100644 --- a/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py +++ b/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py @@ -1,7 +1,7 @@ from playwright.sync_api import Page from shiny.playwright import controller -from shiny.playwright.expect import expect_not_to_have_style, expect_to_have_style +from shiny.playwright.expect import expect_to_have_style from shiny.run import ShinyAppProc @@ -18,28 +18,19 @@ def test_accordion(page: Page, local_app: ShinyAppProc) -> None: # Make sure the `rows` is respected test_text_area_w_rows.expect_rows("4") - # Make sure the placeholder row value of `0` is set - test_text_area.expect_rows("0") + # Make sure the placeholder row value of `1` is set + test_text_area.expect_rows("1") tab.set("Text Area") - textareatext = ( - "How can this UI code be tweaked\n" - "such that this multiline string\n" - "makes the Text Area Input object\n" - "resize itself event though it lives\n" - "inside an Accordion element?" - ) - test_text_area.expect_autoresize(True) - test_text_area.expect_value(textareatext) + test_text_area.expect_value("a\nb\nc\nd\ne") expect_to_have_style(test_text_area.loc, "height", "125px") - expect_not_to_have_style(test_text_area_w_rows.loc, "height") + expect_to_have_style(test_text_area_w_rows.loc, "height", "125px") - # Make sure the placeholder row value of `1` is set + # Make sure the `rows` is consistent test_text_area.expect_rows("1") - # Make sure the `rows` is respected 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 From 725d0958cd43e6601bf05325cf361e6aa6064df4 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 14:26:12 -0400 Subject: [PATCH 6/9] Use a single IntersectionObserver iff one is needed --- js/text-area/textarea-autoresize.ts | 56 +++++++++++-------- .../py-shiny/text-area/textarea-autoresize.js | 29 ++++++---- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/js/text-area/textarea-autoresize.ts b/js/text-area/textarea-autoresize.ts index f0bcb2ca4..2ea64701a 100644 --- a/js/text-area/textarea-autoresize.ts +++ b/js/text-area/textarea-autoresize.ts @@ -18,34 +18,46 @@ function onDelegatedEvent( }); } +// Use a single intersectionObserver as they are slow to create / use. +let textAreaIntersectionObserver: null | IntersectionObserver = null; + +function callUpdateHeightWhenTargetIsVisible(target: HTMLTextAreaElement) { + if (textAreaIntersectionObserver === null) { + // Create a single observer to watch for the textarea becoming visible + textAreaIntersectionObserver = new IntersectionObserver( + (entries, observer) => { + entries.forEach((entry) => { + // Quit if the entry is not visible + if (!entry.isIntersecting) { + return; + } + // If the entry is visible (even if it's just a single pixel) + // Stop observing the target + textAreaIntersectionObserver!.unobserve(entry.target); + + // Update the height of the textarea + update_height(entry.target as HTMLTextAreaElement); + }); + } + ); + } + + textAreaIntersectionObserver.observe(target); +} + function update_height(target: HTMLTextAreaElement) { if (target.scrollHeight > 0) { // Automatically resize the textarea to fit its content. target.style.height = "auto"; target.style.height = target.scrollHeight + "px"; - return; - } - - // The textarea is not visible on the page, therefore it has a 0 scroll height. - - // If we should autoresize the text area height, then we can wait for the textarea to - // become visible and call `update_height` again. Hopefully the scroll height is no - // longer 0 - - // Create an observer to watch for the textarea becoming visible - const observer = new IntersectionObserver((entries, observer) => { - entries.forEach((entry) => { - // If the entry is visible (even if it's just a single pixel) - if (entry.intersectionRatio > 0) { - // Stop observing the target - observer.unobserve(entry.target); + } else { + // The textarea is not visible on the page, therefore it has a 0 scroll height. - // Update the height of the textarea - update_height(entry.target as HTMLTextAreaElement); - } - }); - }); - observer.observe(target); + // If we should autoresize the text area height, then we can wait for the textarea to + // become visible and call `update_height` again. Hopefully the scroll height is no + // longer 0 + callUpdateHeightWhenTargetIsVisible(target); + } } // Update on change diff --git a/shiny/www/py-shiny/text-area/textarea-autoresize.js b/shiny/www/py-shiny/text-area/textarea-autoresize.js index 7cd9354c0..34dca595c 100644 --- a/shiny/www/py-shiny/text-area/textarea-autoresize.js +++ b/shiny/www/py-shiny/text-area/textarea-autoresize.js @@ -7,21 +7,30 @@ function onDelegatedEvent(eventName, selector, callback) { } }); } +var textAreaIntersectionObserver = null; +function callUpdateHeightWhenTargetIsVisible(target) { + if (textAreaIntersectionObserver === null) { + textAreaIntersectionObserver = new IntersectionObserver( + (entries, observer) => { + entries.forEach((entry) => { + if (!entry.isIntersecting) { + return; + } + textAreaIntersectionObserver.unobserve(entry.target); + update_height(entry.target); + }); + } + ); + } + textAreaIntersectionObserver.observe(target); +} function update_height(target) { if (target.scrollHeight > 0) { target.style.height = "auto"; target.style.height = target.scrollHeight + "px"; - return; + } else { + callUpdateHeightWhenTargetIsVisible(target); } - const observer = new IntersectionObserver((entries, observer2) => { - entries.forEach((entry) => { - if (entry.intersectionRatio > 0) { - observer2.unobserve(entry.target); - update_height(entry.target); - } - }); - }); - observer.observe(target); } onDelegatedEvent( "input", From 1532ee7c5f8b900ee075f497a5026023505b2741 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 14:26:37 -0400 Subject: [PATCH 7/9] Move poorly named file to better location --- tests/playwright/shiny/components/accordion/{basic => }/app.py | 0 .../shiny/components/accordion/{basic => }/test_accordion.py | 0 .../accordion => inputs/input_text_area}/autoresize/app.py | 0 .../input_text_area}/autoresize/test_accordion_autoresize.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/playwright/shiny/components/accordion/{basic => }/app.py (100%) rename tests/playwright/shiny/components/accordion/{basic => }/test_accordion.py (100%) rename tests/playwright/shiny/{components/accordion => inputs/input_text_area}/autoresize/app.py (100%) rename tests/playwright/shiny/{components/accordion => inputs/input_text_area}/autoresize/test_accordion_autoresize.py (100%) diff --git a/tests/playwright/shiny/components/accordion/basic/app.py b/tests/playwright/shiny/components/accordion/app.py similarity index 100% rename from tests/playwright/shiny/components/accordion/basic/app.py rename to tests/playwright/shiny/components/accordion/app.py diff --git a/tests/playwright/shiny/components/accordion/basic/test_accordion.py b/tests/playwright/shiny/components/accordion/test_accordion.py similarity index 100% rename from tests/playwright/shiny/components/accordion/basic/test_accordion.py rename to tests/playwright/shiny/components/accordion/test_accordion.py diff --git a/tests/playwright/shiny/components/accordion/autoresize/app.py b/tests/playwright/shiny/inputs/input_text_area/autoresize/app.py similarity index 100% rename from tests/playwright/shiny/components/accordion/autoresize/app.py rename to tests/playwright/shiny/inputs/input_text_area/autoresize/app.py diff --git a/tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py b/tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py similarity index 100% rename from tests/playwright/shiny/components/accordion/autoresize/test_accordion_autoresize.py rename to tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py From 4a50ce847e0b8366991c3f8ead501e167460e2bf Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 16:58:36 -0400 Subject: [PATCH 8/9] Update CHANGELOG.md Co-authored-by: Carson Sievert --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef02f668..4f3c87194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Require shinyswatch >= 0.7.0 and updated examples accordingly. (#1558) -* Fixed bug where an auto resized input text area was not initially auto resized if the element was hidden from view (e.g. in a closed accordion or a hidden tab). (#1560) +* `input_text_area(autoresize=True)` now resizes properly even when it's not visible when initially rendered (e.g. in a closed accordion or a hidden tab). (#1560) ### Bug fixes From f58e195a7d1406f0ea3fb65ed9f302cfee7b0ebb Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 25 Jul 2024 17:23:25 -0400 Subject: [PATCH 9/9] Skip height tests on webkit --- .../input_text_area/autoresize/test_accordion_autoresize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py b/tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py index 37d63d76a..c389b4607 100644 --- a/tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py +++ b/tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py @@ -5,7 +5,7 @@ from shiny.run import ShinyAppProc -def test_accordion(page: Page, local_app: ShinyAppProc) -> None: +def test_accordion(page: Page, local_app: ShinyAppProc, is_webkit: bool) -> None: page.goto(local_app.url) text = controller.OutputCode(page, "text") @@ -26,6 +26,10 @@ def test_accordion(page: Page, local_app: ShinyAppProc) -> None: 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")