Skip to content

fix(cdk/text-field): avoid page jump on auto-resize#32605

Merged
crisbeto merged 1 commit intoangular:mainfrom
CorentinDeBoisset:main
Jan 13, 2026
Merged

fix(cdk/text-field): avoid page jump on auto-resize#32605
crisbeto merged 1 commit intoangular:mainfrom
CorentinDeBoisset:main

Conversation

@CorentinDeBoisset
Copy link
Contributor

When we measure the size of the autosize textarea, we make it temporarily smaller which can cause the scroll position to shift. These changes add a workaround that assign a temporary margin-bottom while measuring.

Fixes #23834

@mmalerba
Copy link
Contributor

mmalerba commented Jan 5, 2026

reassigning to @crisbeto since he was the author of the firefox-specific fix

@mmalerba mmalerba requested a review from crisbeto January 5, 2026 20:07
const element = this._textareaElement;
const previousMargin = element.style.marginBottom || '';
const isFirefox = this._platform.FIREFOX;
const needsMarginFiller = isFirefox && this._hasFocus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need the _hasFocus part of this check. Otherwise we'll end up applying the margin on elements the user isn't interacting with.

When we measure the size of the autosize textarea, we make it temporarily smaller which can cause the scroll position to shift. These changes add a workaround that assign a temporary margin-bottom while measuring.

Fixes angular#23834
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jan 13, 2026
@crisbeto crisbeto merged commit c62c64f into angular:main Jan 13, 2026
10 of 12 checks passed
@crisbeto
Copy link
Member

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto pushed a commit that referenced this pull request Jan 13, 2026
When we measure the size of the autosize textarea, we make it temporarily smaller which can cause the scroll position to shift. These changes add a workaround that assign a temporary margin-bottom while measuring.

Fixes #23834

(cherry picked from commit c62c64f)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: cdk/text-field target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cdkTextareaAutosize): autosize scrolls parent to top at each key hit with ngZoneEventCoalescing enabled

3 participants