-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[TextareaAutosize][TextField] selectionchange
event fires infinitely when multiline
#45307
Comments
Thanks for the report @aaw5017, this definitely looks like a bug. @mj12albert, |
Yes, it's related for sure 🥲 @DiegoAndai All the unwanted events are caused by the hidden textarea, this occurred prior to #44540 as well. Here's a sandbox reverting the RO fix: https://codesandbox.io/p/devbox/focused-bessie-vy64pw?file=%2Fsrc%2FApp.tsx%3A3%2C1-3%2C76 During the resize, the console logs the RO "undelivered notifications" error and also So it's kind of a undiscovered, pre-existing issue that was made worse by the latest fix, not really a regression, at least its discovered now, better late than never 😅 AFTER #44540 What happened here is that:
I made a fix in #45351 to only restart the observation if the height changed. However when using a global const handleSelectionChange = React.useCallback((event: Event) => {
if (event.target instanceof HTMLTextAreaElement && !event.target.ariaHidden) {
console.log('selectionchange, the selection is:', event.target.value);
}
}, []); Demo of the new fix: https://codesandbox.io/p/sandbox/runtime-wood-v4mn8t
@aaw5017 If you would like to test this locally in the mean time: yarn add https://pkg.csb.dev/mui/material-ui/commit/7dfb4fea/@mui/material https://pkg.csb.dev/mui/material-ui/commit/7dfb4fea/@mui/system |
selectionchange
event fires infinitely when multiline
(BTW the placeholder isn't related) |
Steps to reproduce
Steps:
Demo.tsx
fileselectionchange
events being fired continuouslyCurrent behavior
selectionchange
events are being fired constantly if theplaceholder
andmultiline
props are set on theTextField
componentExpected behavior
selectionchange
events should only fire when a user purposely selects text within theTextField
Context
This bug was identified by our users
We have in-house code that taps into
selectionchange
events at the document level. We are setting up the event listener in a similar way to the code sandbox example from above.This bug is saturating our event handler, and our in-house logic no longer works because of it
The breaking patch seems to be
6.4.2
. Rolling back to6.4.1
fixes the issueYour environment
npx @mui/envinfo
This bug was reported to us from a user using Chrome. I reproduced locally with Edge
Search keywords: textfield selectionchange
The text was updated successfully, but these errors were encountered: