Skip to content

Commit 1ff586f

Browse files
cpsievertgadenbuie
andauthored
fix(textarea-autoresize): add a bit of padding when setting textarea height (#1891)
Co-authored-by: Garrick Aden-Buie <[email protected]>
1 parent 6abcb16 commit 1ff586f

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

js/chat/chat.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ shiny-chat-container {
3232
text-underline-offset: 4px;
3333
text-decoration-thickness: 2px;
3434

35-
padding: 2px;
35+
padding-inline: 2px;
3636

3737
&:hover {
3838
text-decoration-style: solid;

js/text-area/textarea-autoresize.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function update_height(target: HTMLTextAreaElement) {
4949
if (target.scrollHeight > 0) {
5050
// Automatically resize the textarea to fit its content.
5151
target.style.height = "auto";
52-
target.style.height = target.scrollHeight + "px";
52+
target.style.height = target.scrollHeight + 2 + "px";
5353
} else {
5454
// The textarea is not visible on the page, therefore it has a 0 scroll height.
5555

shiny/www/py-shiny/chat/chat.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/py-shiny/chat/chat.css.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/py-shiny/text-area/textarea-autoresize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function callUpdateHeightWhenTargetIsVisible(target) {
2727
function update_height(target) {
2828
if (target.scrollHeight > 0) {
2929
target.style.height = "auto";
30-
target.style.height = target.scrollHeight + "px";
30+
target.style.height = target.scrollHeight + 2 + "px";
3131
} else {
3232
callUpdateHeightWhenTargetIsVisible(target);
3333
}

tests/playwright/shiny/inputs/input_text_area/autoresize/test_accordion_autoresize.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def test_accordion(page: Page, local_app: ShinyAppProc, is_webkit: bool) -> None
3030
# Skip the rest of the test for webkit.
3131
# Heights are not consistent with chrome and firefox
3232
return
33-
expect_to_have_style(test_text_area.loc, "height", "125px")
34-
expect_to_have_style(test_text_area_w_rows.loc, "height", "125px")
33+
expect_to_have_style(test_text_area.loc, "height", "127px")
34+
expect_to_have_style(test_text_area_w_rows.loc, "height", "127px")
3535

3636
# Make sure the `rows` is consistent
3737
test_text_area.expect_rows("1")
@@ -42,6 +42,6 @@ def test_accordion(page: Page, local_app: ShinyAppProc, is_webkit: bool) -> None
4242
test_text_area_w_rows.set("single row")
4343

4444
# 1 row
45-
expect_to_have_style(test_text_area.loc, "height", "35px")
45+
expect_to_have_style(test_text_area.loc, "height", "37px")
4646
# 4 rows
47-
expect_to_have_style(test_text_area_w_rows.loc, "height", "102px")
47+
expect_to_have_style(test_text_area_w_rows.loc, "height", "104px")

0 commit comments

Comments
 (0)