diff --git a/docs/docs/resources/changelog.md b/docs/docs/resources/changelog.md index 3247b4502..55bc8c0c1 100644 --- a/docs/docs/resources/changelog.md +++ b/docs/docs/resources/changelog.md @@ -28,6 +28,7 @@ During the alpha period, things might break! We take breaking changes very serio - Fixed a bug in `` that prevented label changes in `` from updating the controller - Fixed a bug in `` that caused interactive elements to be activated when dragging - Fixed a bug in `` that prevented changing tabs by setting `active` on `` elements +- Fixed a bug in `` causing scroll jumping when using `resize="auto"` - Improved alignment of the play icon in `` - Improved behavior of link buttons to not set `noreferrer noopener` by default diff --git a/src/components/textarea/textarea.styles.ts b/src/components/textarea/textarea.styles.ts index 174cbdc21..d96b5ccf1 100644 --- a/src/components/textarea/textarea.styles.ts +++ b/src/components/textarea/textarea.styles.ts @@ -24,7 +24,7 @@ export default css` border-style: var(--border-style); border-width: var(--border-width); box-shadow: var(--box-shadow); - display: flex; + display: grid; align-items: center; position: relative; width: 100%; @@ -38,6 +38,17 @@ export default css` cursor: text; } + .textarea__control, + .textarea__size-adjuster { + grid-area: 1 / 1 / 2 / 2; + } + + .textarea__size-adjuster { + visibility: hidden; + pointer-events: none; + opacity: 0; + } + /* Standard textareas */ .textarea--standard.textarea--focused:not(.textarea--disabled) { outline: var(--wa-focus-ring); @@ -62,7 +73,6 @@ export default css` } .textarea__control { - flex: 1 1 auto; font: inherit; line-height: var(--wa-line-height-expanded); color: var(--wa-form-control-value-color); diff --git a/src/components/textarea/textarea.ts b/src/components/textarea/textarea.ts index a752db722..33adf15c0 100644 --- a/src/components/textarea/textarea.ts +++ b/src/components/textarea/textarea.ts @@ -57,6 +57,7 @@ export default class WaTextarea extends WebAwesomeFormAssociatedElement { private resizeObserver: ResizeObserver; @query('.textarea__control') input: HTMLTextAreaElement; + @query('.textarea__size-adjuster') sizeAdjuster: HTMLTextAreaElement; @state() private hasFocus = false; @property() title = ''; // make reactive to pass through @@ -225,6 +226,8 @@ export default class WaTextarea extends WebAwesomeFormAssociatedElement { private setTextareaHeight() { if (this.resize === 'auto') { + // This prevents layout shifts. We use `clientHeight` instead of `scrollHeight` to account for if the ` + + +