File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,23 @@ export default function autosize(textarea) {
4848 return
4949 }
5050
51- const maxHeight = Number ( getComputedStyle ( textarea ) . height . replace ( / p x / , '' ) ) + bottom
51+ const textareaStyle = getComputedStyle ( textarea )
52+
53+ const topBorderWidth = Number ( textareaStyle . borderTopWidth . replace ( / p x / , '' ) )
54+ const bottomBorderWidth = Number ( textareaStyle . borderBottomWidth . replace ( / p x / , '' ) )
55+
56+ const isBorderBox = textareaStyle . boxSizing === 'border-box'
57+ const borderAddOn = isBorderBox ? topBorderWidth + bottomBorderWidth : 0
58+
59+ const maxHeight = Number ( textareaStyle . height . replace ( / p x / , '' ) ) + bottom
5260 textarea . style . maxHeight = `${ maxHeight - 100 } px`
5361
5462 const container = textarea . parentElement
5563 if ( container instanceof HTMLElement ) {
5664 const containerHeight = container . style . height
5765 container . style . height = getComputedStyle ( container ) . height
5866 textarea . style . height = 'auto'
59- textarea . style . height = `${ textarea . scrollHeight } px`
67+ textarea . style . height = `${ textarea . scrollHeight + borderAddOn } px`
6068 container . style . height = containerHeight
6169 height = textarea . style . height
6270 }
You can’t perform that action at this time.
0 commit comments