Skip to content

Commit be2b744

Browse files
authored
fix(textarea): fix height logic for autoresize textarea (#11922)
* fix(textarea): fix height logic for autoresize textarea * fix(textarea): update snapshot
1 parent 14e29d8 commit be2b744

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/react-core/src/components/TextArea/TextArea.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ class TextAreaBase extends Component<TextAreaProps> {
6262
const parent = field.parentElement;
6363
parent.style.setProperty('height', 'inherit');
6464
const computed = window.getComputedStyle(field);
65+
const parentComputed = window.getComputedStyle(parent);
6566
// Calculate the height
6667
const height =
6768
parseInt(computed.getPropertyValue('border-top-width')) +
68-
parseInt(computed.getPropertyValue('padding-top')) +
6969
field.scrollHeight +
70-
parseInt(computed.getPropertyValue('padding-bottom')) +
71-
parseInt(computed.getPropertyValue('border-bottom-width'));
70+
parseInt(computed.getPropertyValue('border-bottom-width')) +
71+
parseInt(parentComputed.getPropertyValue('padding-top')) +
72+
parseInt(parentComputed.getPropertyValue('padding-bottom'));
73+
7274
parent.style.setProperty('height', `${height}px`);
7375
};
7476

packages/react-core/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`Matches the snapshot 1`] = `
44
<DocumentFragment>
55
<span
66
class="pf-v6-c-form-control pf-m-textarea pf-m-resize-both pf-m-disabled custom class"
7-
style="height: 6px;"
7+
style="height: inherit;"
88
>
99
<textarea
1010
aria-invalid="false"

0 commit comments

Comments
 (0)