Skip to content
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

[TextareaAutosize] ResizeObserver loop completed with undelivered notifications (when resizing view with TextArea with scroll inside) #167

Open
clement-faure opened this issue Sep 22, 2023 · 50 comments
Assignees
Labels
component: TextareaAutosize The React component. priority: important This change can make a difference

Comments

@clement-faure
Copy link

clement-faure commented Sep 22, 2023

Steps to reproduce 🕹

Link to live example:

Steps:

  1. Create view with TextArea component
  2. Set rows props to 2
  3. Set default value to long text
  4. Try resizing view

Current behavior 😯

All seems to works fine at first view but sentry report a "ResizeObserver loop completed with undelivered notifications." error.

Expected behavior 🤔

No error should occur

Context 🔦

No response

Your environment 🌎

 System:
    OS: macOS 13.5.2
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 116.0.5845.187
    Edge: Not Found
    Safari: 16.6
  npmPackages:
    @emotion/react: ^11.11.1 => 11.11.1 
    @emotion/styled: ^11.11.0 => 11.11.0 
    @mui/base:  5.0.0-beta.16 
    @mui/core: ^5.0.0-alpha.54 => 5.0.0-alpha.54 
    @mui/core-downloads-tracker:  5.14.10 
    @mui/envinfo: ^2.0.9 => 2.0.9 
    @mui/icons-material: ^5.14.9 => 5.14.9 
    @mui/material: ^5.14.10 => 5.14.10 
    @mui/private-theming:  5.14.10 
    @mui/styled-engine:  5.14.10 
    @mui/system:  5.14.10 
    @mui/types:  7.2.4 
    @mui/utils:  5.14.10 
    @types/react: ^18.2.21 => 18.2.21 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    typescript: ^5.2.2 => 5.2.2 

Search keywords:

@clement-faure clement-faure added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 22, 2023
@zannager zannager added the component: TextareaAutosize The React component. label Sep 22, 2023
@samuelsycamore

This comment was marked as resolved.

@samuelsycamore samuelsycamore added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 10, 2023
@ps-mladen-savic
Copy link

I have the same issue, when I add 'multiline' property to TextField.

@stevemckenzie

This comment was marked as resolved.

@github-actions

This comment was marked as resolved.

@ZonicaP

This comment was marked as resolved.

@marthrusk

This comment was marked as resolved.

@samuelsycamore
Copy link
Member

Reopening this since we're getting more reports that seem to be related. Can anyone share a reproduction of the problem?

@github-actions

This comment was marked as resolved.

@samuelsycamore samuelsycamore removed the status: waiting for author Issue with insufficient information label Oct 23, 2023
@ShafiaShahid

This comment was marked as resolved.

@ryan-saffer
Copy link

I was facing the same error, and also had multiline on my <TextField />. The error disappeared when I added the property rows={1} to the <TextField />.

I was unable to reproduce the error on CodePen, but hopefully this helps others!

@monteiz
Copy link

monteiz commented Nov 4, 2023

I can also confirm that using the multiline attribute in the TextField component is raising the exception ResizeObserver loop completed with undelivered notifications.

I am using:

"@mui/material": "^5.14.16",
"@mui/styles": "^5.14.16",
"react": "^17.0.2",
"react-dom": "^17.0.2"

It's worth noting that the warning appears occasionally on page refresh (about 80% of the times).

@ryan-saffer adding rows={1} as a workaround did not work for me. The only way is to remove the multiline attribute.

@monteiz
Copy link

monteiz commented Nov 4, 2023

I could at least isolate the problem. In my case, it was lying into the main mustache template. This is a simplified version that I hope it helps you to reproduce the issue:

<!doctype html>
<html>
	<head>
		<style>
			div.hidden {
				display: none !important;
			}
		</style>
	</head>

	<body>
		<div id="main" class="hidden">{{ html }}</div>

		<script
			src="https://localhost:9004/bundle.js?{{ webpack_hash }}"
			type="text/javascript"
		></script>

		<script>
			function hidePreloader() {
				const el = document.querySelector("#main");
				el.classList.remove("hidden"); // this line is causing the warning to appear
			}

			document.body.onload = hidePreloader;
		</script>
	</body>
</html>

The warning stops appearing if I comment out the line

el.classList.remove("hidden");

This is the client code, reduced to the minimum:

import React from "react";
import ReactDOM from "react-dom";
import TextField from "@mui/material/TextField/index.js";

const App = () => {
	return <TextField multiline></TextField>;
};

ReactDOM.render(<App />, document.querySelector("#main"));

@abuuer
Copy link

abuuer commented Nov 6, 2023

I faced the same error while using multiline inside <TextField />. The error seemed to be reproduced everytime I resize the page, and occurs at the exact moment when the scrollbar appears inside the TextField as shown in the second picture. The error disappears when I remove multiline. However, I am still trying to reproduce the error in codesandbox with no luck so far.
1 2

@Dzemik55
Copy link

Dzemik55 commented Nov 8, 2023

I also face this error. I use <TextField /> with multiline, fullWidth and maxRows={Infinity} and it happens when I resize the window. I tried to reproduce the error in codesandbox but it just doesn't occur there.

@cpetersonco
Copy link

I am also encountering this issue. It seems like this error is already being handled in the test environment, so we may need to apply the error handling here in TextareaAutosize.tsx to all environments.

@beyonditsolutions
Copy link

I have exactly the same issue with MUI 5.14.11! The only thing I can add, it only happens when the breakpoint SM (600px width) is passed!

@adamplonka
Copy link

adamplonka commented Nov 13, 2023

I'm having the same issue. Actually the whole code needed to reproduce this issue is just:

<Textarea />

Then put some long text in it and an error will appear whenever number of lines changes due to window resizing.

Codesandbox to reproduce:
https://codesandbox.io/s/compassionate-clarke-fzzvjv?file=/src/App.js

It happens only when the whole window resizes, so it doesn't work on codesandbox and webpack gives us a nasty red overlay with this error but in this example, I attached to the error window event to show the error in the console.

@TamNhiDuong
Copy link

I got the same problem with multiline TextInput. Reproduce by copying exact example code in MUI website:
<TextField id="outlined-multiline-static" label="Multiline" multiline rows={4} defaultValue="Default Value" />

And the error message is:

ERROR
ResizeObserver loop completed with undelivered notifications.
at handleError (http://localhost:3000/viewer4/static/js/bundle.js:175233:58)
at http://localhost:3000/viewer4/static/js/bundle.js:175252:7

@ChrisB1123
Copy link

I'm having the same issue. Actually the whole code needed to reproduce this issue is just:

<Textarea />

Then put some long text in it and an error will appear whenever number of lines changes due to window resizing.

Codesandbox to reproduce: https://codesandbox.io/s/compassionate-clarke-fzzvjv?file=/src/App.js

It happens only when the whole window resizes, so it doesn't work on codesandbox and webpack gives us a nasty red overlay with this error but in this example, I attached to the error window event to show the error in the console.

Similar issue to this for me. If I add the maxRows prop, then the error no longer appears.

@hiro-daikin
Copy link

hiro-daikin commented Jan 12, 2024

Found a workaround using InputProps.

  <TextField
      InputProps={{
          rows: 18,
          multiline: true,
          inputComponent: 'textarea'
      }}
  />

@waytothevenus
Copy link

waytothevenus commented Jan 12, 2024

I've faced the same problem and fixed with this code.

`import { ResizeObserver } from '@juggle/resize-observer';

const ro = new ResizeObserver((entries, observer) => {
// Changing the body size inside of the observer
// will cause a resize loop and the next observation will be skipped
document.body.style.width = '50%';
});

// Listen for errors
window.addEventListener('error', e => console.log(e.message));

// Observe the body
ro.observe(document.body);`

@phudtran
Copy link

Also seeing this in JoyUI
Repros on the Textarea component page

https://mui.com/joy-ui/react-textarea/

On MacOS Safari, repros with zooming in/out (Command +/-)

image

@danielroccha

This comment was marked as resolved.

@nickluger
Copy link

Found a workaround using InputProps.

  <TextField
      InputProps={{
          rows: 18,
          multiline: true,
          inputComponent: 'textarea'
      }}
  />

That's no longer resizing in my case.

@maxwell-stemlogic
Copy link

This issue is intermittently ongoing.

Using "@mui/material": "^5.15.7"
The issue persisted even after changing to version 5.14.7
Rows={5} does not fix it as well.

@malashevskyi
Copy link

I'm having the same issue. Actually the whole code needed to reproduce this issue is just:

<Textarea />

Then put some long text in it and an error will appear whenever number of lines changes due to window resizing.

Codesandbox to reproduce: https://codesandbox.io/s/compassionate-clarke-fzzvjv?file=/src/App.js

It happens only when the whole window resizes, so it doesn't work on codesandbox and webpack gives us a nasty red overlay with this error but in this example, I attached to the error window event to show the error in the console.

The same error occurs when the placeholder does not fit in the input size.
An error is shown every time a placeholder is moved to a new line.

codesandbox to reproduce

2024-02-07_12-24

@samuelsycamore
Copy link
Member

samuelsycamore commented Feb 7, 2024

It appears that this issue may be related to mui/material-ui#37135 and/or mui/material-ui#38728 given the timing. It showed up in testing in mui/material-ui#40929 (comment).

@iam-gopi
Copy link

I too facing the same issue couldnt able to fix it. I've not used any UI library except Tailwind css classes here is the code of my textarea

<textarea id="address" rows="4" class="block p-2.5 w-full text-lg text-gray-900 rounded-lg border-0 border-b-2 bg-transparent focus:border-primaryRed focus:outline-none " placeholder="Provide address here" name="address" onChange={handleChange} autoComplete="false" aria-autocomplete="none" value={formData.address} ></textarea>

Im getting this error when I click on the textarea to enter something. Here is the screenshot of the error message
image

@oneQiu
Copy link

oneQiu commented Feb 22, 2024

同样出现这个问题,很烦心了。
image

@oliviertassinari oliviertassinari changed the title ResizeObserver loop completed with undelivered notifications (when resizing view with TextArea with scroll inside) [TextareaAutosize] ResizeObserver loop completed with undelivered notifications (when resizing view with TextArea with scroll inside) Mar 10, 2024
@oliviertassinari oliviertassinari transferred this issue from mui/material-ui Mar 10, 2024
@alexasparks
Copy link

alexasparks commented Mar 19, 2024

This was an issue for me too! For now I'm replacing my multiline TextField with InputBase and adjusting styles. It gets rid of the resize error in my environment. We'll see what happens in Sentry once I get the update deployed.

@luke-ken
Copy link

luke-ken commented Mar 20, 2024

I've also encountered the same issue while using the <TextField/> from @mui/material, although my usage is a bit different.
I'm using multiline together with maxRows in a <TextField/> that has no specific width.

<TextField
      multiline
      maxRows={2}
/>

Here is a simple codesandbox to reproduce.

@mohsinulhaq-deshaw
Copy link

Hi team, were we able to get closer to the bottom of this issue?
Could someone from the core team shed some light on what their hunch on this is and what could be the potential solutions?
We would be happy to help, given proper guidance.

This has been flooding our error logs, particularly from users who are triggering resizes on the multiline TextFields.

@colmtuite
Copy link

Auto-sizing can be handled natively these days with field-sizing. So we're going to deprecate this component soon.

Demo

@waigel
Copy link

waigel commented Mar 21, 2024

I respectfully disagree; the suggested solution isn't sufficient. Though the new CSS variable could replace MUI's current approach, we're not there yet. Please reopen the ticket so we can address the ResizeObserver problem.

image

@colmtuite
Copy link

What I meant to say was that it should be well-supported soon, and our new Textarea component (based on our new API design) wouldn't be roadmapped until the field-sizing is well-supported anyway.

But I'll reopen for now and we'll chat internally next week. I'll update again next week after we chat.

@colmtuite colmtuite reopened this Mar 21, 2024
@adrianbunea

This comment was marked as resolved.

@alirezavafaee
Copy link

It may help,
Solving ResizeObserver Errors
https://medium.com/@chamaraS/resizeobserver-for-react-developers-a91df3608944

@valeriavodianchuk
Copy link

Any updates?

@prechapl
Copy link

prechapl commented May 8, 2024

I am getting the errors while using <TextField InputProps={{ multiline: true}} ... /> in 5.15.14. Does anyone know if upgrading to v6 or v7 would fix the issue?

@oliviertassinari oliviertassinari added the priority: important This change can make a difference label May 9, 2024
@PastaLaPate
Copy link

I'm getting the same error just if I use a native <textarea> is this a wepback, or a react problem ?

@avalenti89
Copy link

avalenti89 commented May 17, 2024

My working workaround
.MuiTextField-root.MuiFormControl-fullWidth{ width: 100vw; max-width: 100%; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TextareaAutosize The React component. priority: important This change can make a difference
Projects
None yet
Development

No branches or pull requests