Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoresizeTextarea computes incorrect height in some cases #2312

Closed
Diggsey opened this issue Mar 4, 2025 · 1 comment
Closed

autoresizeTextarea computes incorrect height in some cases #2312

Diggsey opened this issue Mar 4, 2025 · 1 comment

Comments

@Diggsey
Copy link

Diggsey commented Mar 4, 2025

🐛 Bug report

Logical integer border widths may translate to fractional physical pixel widths due to DPI scaling. Browsers try to mitigate this by rounding the border width to an integer number of physical pixels. This means the following calculation is incorrect:

const borderTopWidth = parseInt(style.borderTopWidth, 10)
const borderBottomWidth = parseInt(style.borderBottomWidth, 10)
el.style.height = `${el.scrollHeight + borderTopWidth + borderBottomWidth}px`

This results in unwanted scrollbars on the textarea, because it's 1 pixel too short.

💥 Steps to reproduce

Use the auto-resizing textarea on a high-DPI display in Firefox.

CodeSandbox reproduction: https://www.chakra-ui.com/docs/components/textarea#autoresize

🧐 Expected behavior

The textarea should not have scrollbars.

🧭 Possible Solution

Compute an accurate height, or err on the large side.

🌍 System information

Software Version(s)
Zag Version all
Browser Firefox
Operating System Windows 10

📝 Additional information

Image

@segunadebayo
Copy link
Member

I just pushed a fix for this. We'll release an update shortly.

If the issue persists after upgrading, I'll re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants