Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

wrong max height when using maxRows and boxSizing "border-box" #86

Open
FrancescoCioria opened this issue Dec 13, 2017 · 1 comment
Open

Comments

@FrancescoCioria
Copy link
Contributor

FrancescoCioria commented Dec 13, 2017

description

If the textarea has box-sizing: border-box and some padding, the max height computed to have the desired maxRows is wrong.

how to reproduce

  • <TextareaAutosize style={{ boxSizing: 'border-box', padding: 10 }} maxRows={3} />

specs

if this.props.maxRows then pass { boxSizing: 'content-box' } to the textarea by default as style.
this inline style should be overridable by this.props.style

misc

{optional: other useful info}

@supersetapp
Copy link

supersetapp commented Feb 5, 2020

I ran into a similar issue when I’m passing in style={{ maxWidth: '330px' }} to a component that also has CSS giving it 20px padding and box-sizing border-box.

I tested this out directly with the autosize library and I was unable to reproduce the issue. I found that if I added the additional style values: { overflow: hidden; overflow-wrap: break-word; }, then the scroll bars disappeared. I noticed that when I ran autosize directly it was adding that styling to my textarea, so I tested it out in my react case and it worked like a charm.

I think there should be a better solution than the one proposed in PR #87 — because that one is just overriding style to make things box-sizing: content-box, which could lead to unexpected rendering bugs for developers, e.g., if you made { width: 100%; padding: 20px; } change from border-box to content-box, then the textarea would suddenly expand 40px wider than it’s container.

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

No branches or pull requests

3 participants