Skip to content

fix(cdk/text-field): Long multiline textfield focus issue #30312

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

Conversation

mistrykaran91
Copy link
Contributor

@mistrykaran91 mistrykaran91 commented Jan 13, 2025

When we have a long multiline textfield and put the cursor on almost an end (For example, on 3rd last line), the scroll moves up to the top of textarea. This fix will cache the scrollTop in theresizeToFitContent method

Fixes #20255

@mistrykaran91 mistrykaran91 requested a review from a team as a code owner January 13, 2025 06:35
@mistrykaran91 mistrykaran91 requested review from mmalerba and wagnermaciel and removed request for a team January 13, 2025 06:35
@mistrykaran91 mistrykaran91 changed the title fix(cdk/text-field): Long multiline textfield focus issue. fix(cdk/text-field): Long multiline textfield focus issue Jan 13, 2025
@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch from a6c08d5 to c7256b2 Compare February 13, 2025 09:53
@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch 3 times, most recently from 60af3c5 to aff4247 Compare March 4, 2025 12:30
@mistrykaran91 mistrykaran91 requested a review from mmalerba March 4, 2025 12:36
@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch 2 times, most recently from dc6c818 to 4e82db5 Compare March 6, 2025 06:54
@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch from 4e82db5 to 7a6fb23 Compare March 10, 2025 08:17
@mistrykaran91 mistrykaran91 requested a review from mmalerba March 10, 2025 10:15
@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch from 7a6fb23 to ef1303f Compare March 10, 2025 11:59
@mistrykaran91
Copy link
Contributor Author

mistrykaran91 commented Mar 11, 2025

@mmalerba, #8992 seems to be a similar issue.

@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch from ef1303f to 03ed47b Compare March 13, 2025 07:01
When we have long multiline textfield and put cursor on almost an end (For eg. on 3rd last line) the scroll moves up to the top of textarea. This fix will cache the `scrollTop` in `resizeToFitContent` method

Fixes angular#20255
@mistrykaran91 mistrykaran91 force-pushed the bugfix/long-multiline-textfield-scroll-issue branch from 03ed47b to a9be63e Compare March 13, 2025 07:11
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Mar 18, 2025
@mistrykaran91
Copy link
Contributor Author

@mmalerba let me know if you want me to rebase the branch with the latest changes in main.

@mmalerba
Copy link
Contributor

It looks like there's no conflicts so its fine for now, we just need to run it against google's internal tests and see if anything fails

@mmalerba mmalerba self-assigned this Mar 18, 2025
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Mar 19, 2025
@mmalerba mmalerba removed the request for review from wagnermaciel March 19, 2025 00:24
@mmalerba mmalerba merged commit dc70692 into angular:main Mar 19, 2025
22 of 24 checks passed
mmalerba pushed a commit that referenced this pull request Mar 19, 2025
When we have long multiline textfield and put cursor on almost an end (For eg. on 3rd last line) the scroll moves up to the top of textarea. This fix will cache the `scrollTop` in `resizeToFitContent` method

Fixes #20255

(cherry picked from commit dc70692)
@mistrykaran91 mistrykaran91 deleted the bugfix/long-multiline-textfield-scroll-issue branch March 19, 2025 06:09
@mistrykaran91
Copy link
Contributor Author

@mmalerba just to be double sure won't it fix this one too - #8992 ? Or I'm missing something

@Sn0oze
Copy link

Sn0oze commented Apr 4, 2025

Today I updated the CDK version from v18.x to v19.2.8 during the Angular v18 to v19 migration of our mono repo and noticed a regression in our textarea component that uses the CdkTextareaAutosize.
After some bisecting, I conclude that this fix must be the cause as the regression appears from version 19.2.4 and onwards, which is the first release that includes this fix.

The regression happens when enough rows have been inserted at the bottom of the text area to reach the maxRows limit and cause the textarea to overflow.
While inserting new rows, the scroll container does not properly scroll to the inserted rows.
This bug can also be observed on the official Auto-resizing textarea example.
To reproduce the bug it is enough to focus the text area and keep the enter key pressed.
The same interaction works as expected in v18 of the Auto-resizing textarea example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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(text field): Long multiline text field - scrolled up on input
3 participants