LeaVerou / stretchy

Form element autosizing, the way it should be
https://stretchy.verou.me/
Other
1.27k stars 87 forks source link

Fix calculation for box-sizing on textareas #43

Closed dpschen closed 2 years ago

netlify[bot] commented 2 years ago

✔️ Deploy Preview for stretchy-forms ready!

🔨 Explore the source changes: 3d13ce770e55bbbb8ea73c16ea41399a5b5efb0c

🔍 Inspect the deploy log: https://app.netlify.com/sites/stretchy-forms/deploys/61a140f1f70b7a000755b993

😎 Browse the preview: https://deploy-preview-43--stretchy-forms.netlify.app

LeaVerou commented 2 years ago

Hi there, thanks for submitting this PR! Could you elaborate a bit on this change? Does it fix one of your use cases that was previously broken? I looked at the deploy preview and can't spot any change for <input>. I can spot the improvement in <textarea>. Can't spot any visual change in the testsuite either.

dpschen commented 2 years ago

Indeed! I went a bit overboard with also adjusting the method for inputs. The problem I had was only affecting a textarea. I'll adjust this fix =)

LeaVerou commented 2 years ago

Merged, though it worries me a bit that this wasn't there all these years even though the conditional branches off box-sizing anyway.

dpschen commented 2 years ago

Yes. I'm still not convinced if this is the right — and especially complete – fix, but it seems to be a "more accurate" way to do this, since offsetHeight should include padding (but also the border) when height is set to 0.

I discovered an issue with the box-sizing calculation when I tried the resize method isolated in a project (the use case is very specific to one <textarea> so there was no need for all the extra logic).

I'm having a hard time to extract a good isolated test from that project but if I have some more / other insights I'll share it =)