Skip to content

fix: include border width in max-height calculation (#9213) (CP: 24.7) #9216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/text-area/src/vaadin-text-area-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ export const TextAreaMixin = (superClass) =>
parseFloat(inputStyle.paddingBottom) +
parseFloat(inputStyle.marginTop) +
parseFloat(inputStyle.marginBottom) +
parseFloat(inputFieldStyle.borderTopWidth) +
parseFloat(inputFieldStyle.borderBottomWidth) +
parseFloat(inputFieldStyle.paddingTop) +
parseFloat(inputFieldStyle.paddingBottom);
const maxHeight = Math.ceil(contentHeight + marginsAndPaddings);
Expand Down
6 changes: 4 additions & 2 deletions packages/text-area/test/text-area.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe('text-area', () => {
expect(textArea.clientHeight).to.equal(lineHeight * 4);
});

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

textArea.maxRows = 4;
textArea.value = Array(400).join('400');
await nextUpdate(textArea);

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

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