Skip to content

Commit e3e47fd

Browse files
vaadin-botjounisissbruecker
authored
fix: include border width in max-height calculation (#9213) (#9215)
* fix: include border width in max-height calculation * update test --------- Co-authored-by: Jouni Koivuviita <jouni@vaadin.com> Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent 3dd82a0 commit e3e47fd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/text-area/src/vaadin-text-area-mixin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ export const TextAreaMixin = (superClass) =>
235235
parseFloat(inputStyle.paddingBottom) +
236236
parseFloat(inputStyle.marginTop) +
237237
parseFloat(inputStyle.marginBottom) +
238+
parseFloat(inputFieldStyle.borderTopWidth) +
239+
parseFloat(inputFieldStyle.borderBottomWidth) +
238240
parseFloat(inputFieldStyle.paddingTop) +
239241
parseFloat(inputFieldStyle.paddingBottom);
240242
const maxHeight = Math.ceil(contentHeight + marginsAndPaddings);

packages/text-area/test/text-area.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ describe('text-area', () => {
363363
expect(textArea.clientHeight).to.equal(lineHeight * 4);
364364
});
365365

366-
it('should include margins and paddings when calculating max-height', async () => {
366+
it('should include margins, paddings and borders when calculating max-height', async () => {
367367
const native = textArea.querySelector('textarea');
368368
const inputContainer = textArea.shadowRoot.querySelector('[part="input-field"]');
369369
native.style.paddingTop = '5px';
@@ -372,12 +372,14 @@ describe('text-area', () => {
372372
native.style.marginBottom = '20px';
373373
inputContainer.style.paddingTop = '25px';
374374
inputContainer.style.paddingBottom = '30px';
375+
inputContainer.style.borderTop = 'solid 35px';
376+
inputContainer.style.borderBottom = 'solid 40px';
375377

376378
textArea.maxRows = 4;
377379
textArea.value = Array(400).join('400');
378380
await nextUpdate(textArea);
379381

380-
expect(textArea.clientHeight).to.equal(lineHeight * 4 + 5 + 10 + 15 + 20 + 25 + 30);
382+
expect(textArea.clientHeight).to.equal(lineHeight * 4 + 5 + 10 + 15 + 20 + 25 + 30 + 35 + 40);
381383
});
382384

383385
it('should shrink below max-height defined by maximum rows', async () => {

0 commit comments

Comments
 (0)