-
-
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
Open
Hukumchand-Narwre
wants to merge
19
commits into
mui:master
Choose a base branch
from
Hukumchand-Narwre:multiline-textfield-height-issues
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
50d7c7d
[TextField] Fix Backspacing after line break in multiline causes heig…
Hukumchand-Narwre 298dd88
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre ee25462
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 2225183
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 21b92c6
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 2ae30dc
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 96e0ad7
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 6dca6e9
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 9980173
comments resolved
Hukumchand-Narwre dfd60ff
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre f0dc09b
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre d972091
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 0e49052
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 70c45ac
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 71cb972
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre c7742d4
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 4a6c4b5
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 737074e
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre 32c619d
Merge branch 'master' into multiline-textfield-height-issues
Hukumchand-Narwre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import useForkRef from '@mui/utils/useForkRef'; | |||||
| import useEnhancedEffect from '@mui/utils/useEnhancedEffect'; | ||||||
| import useEventCallback from '@mui/utils/useEventCallback'; | ||||||
| import ownerWindow from '@mui/utils/ownerWindow'; | ||||||
| import ownerDocument from '@mui/utils/ownerDocument'; | ||||||
| import { TextareaAutosizeProps } from './TextareaAutosize.types'; | ||||||
|
|
||||||
| function getStyleValue(value: string) { | ||||||
|
|
@@ -153,6 +154,21 @@ const TextareaAutosize = React.forwardRef(function TextareaAutosize( | |||||
| if (heightRef.current !== outerHeightStyle) { | ||||||
| heightRef.current = outerHeightStyle; | ||||||
| textarea.style.height = `${outerHeightStyle}px`; | ||||||
|
|
||||||
| // 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); | ||||||
| const selectionStart = textarea.selectionStart; | ||||||
| const selectionEnd = textarea.selectionEnd; | ||||||
| const tempValue = textarea.value; | ||||||
| textarea.value = ''; | ||||||
| // eslint-disable-next-line @typescript-eslint/no-unused-expressions | ||||||
| textarea.offsetHeight; | ||||||
|
||||||
| textarea.offsetHeight; | |
| void textarea.offsetHeight; |
Does this work instead of eslint-disable?
Author
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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