Skip to content

Commit a1ca79c

Browse files
authored
Merge pull request #104 from r4b6i0/master
fix(): wrong height calculation when textarea has a padding
2 parents f91f32d + 0725936 commit a1ca79c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

projects/ngx-autosize/src/lib/autosize.directive.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ export class AutosizeDirective implements OnDestroy, OnChanges, AfterContentChec
159159
height += parseInt(computedStyle.getPropertyValue('border-top-width'));
160160
height += parseInt(computedStyle.getPropertyValue('border-bottom-width'));
161161

162-
// add into height top and bottom paddings width
163-
height += parseInt(computedStyle.getPropertyValue('padding-top'));
164-
height += parseInt(computedStyle.getPropertyValue('padding-bottom'));
165-
162+
if (computedStyle.getPropertyValue('box-sizing') === 'content-box') {
163+
height -= parseInt(computedStyle.getPropertyValue('padding-top'));
164+
height -= parseInt(computedStyle.getPropertyValue('padding-bottom'));
165+
}
166166

167167
const oldHeight = this.textAreaEl.offsetHeight;
168168
const willGrow = height > oldHeight;

0 commit comments

Comments
 (0)