-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[TextField] Fix Backspacing after line break in multiline causes heig… #47443
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
base: master
Are you sure you want to change the base?
[TextField] Fix Backspacing after line break in multiline causes heig… #47443
Conversation
…ht issues on Safari
Netlify deploy previewhttps://deploy-preview-47443--material-ui.netlify.app/ Bundle size report
|
| const tempValue = textarea.value; | ||
| textarea.value = ''; | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-expressions | ||
| textarea.offsetHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| textarea.offsetHeight; | |
| void textarea.offsetHeight; |
Does this work instead of eslint-disable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it worked without eslint-disable
|
|
||
| // This is a workaround for Safari/WebKit not reflowing text when the textarea height changes | ||
| // Force Safari to reflow the text by manipulating the textarea value | ||
| const containerDocument = ownerDocument(textarea); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just webkit we could wrap this change with a check:
const isWebKit = typeof CSS === 'undefined' || !CSS.supports
? false
: CSS.supports('-webkit-backdrop-filter:none');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapped the changes to work only in WebKit
|
Thank you, @mj12albert, for reviewing the PR. Required changes are done, please review again |
This is my first Open source contribution. This PR fixes an issue in
TextFieldheight when the multiline prop is passed.Root Cause
In safari when textarea height is reduced programmatically, Safari updates the height but does not recalculate text line wrapping & caret position. Chrome handles this correctly
Proposed Fix
We can force textline wrapping recalculation in Safari by changing the textArea width.
Fixes
Fixes #45293