Skip to content

Commit

Permalink
try out requestAnimationFrame in production
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeshanTamboli committed May 5, 2024
1 parent 056721b commit aaa1c65
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/mui-base/src/TextareaAutosize/TextareaAutosize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ const TextareaAutosize = React.forwardRef(function TextareaAutosize(
const handleResize = () => {
syncHeight();
};
// Workaround a "ResizeObserver loop completed with undelivered notifications" error
// in test.
// Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38
// Also see https://github.com/mui/mui-x/issues/8733
// Workaround a "ResizeObserver loop completed with undelivered notifications" error.
let rAF: any;
const rAFHandleResize = () => {
cancelAnimationFrame(rAF);
Expand All @@ -159,9 +156,7 @@ const TextareaAutosize = React.forwardRef(function TextareaAutosize(
let resizeObserver: ResizeObserver;

if (typeof ResizeObserver !== 'undefined') {
resizeObserver = new ResizeObserver(
process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize,
);
resizeObserver = new ResizeObserver(rAFHandleResize);
resizeObserver.observe(input);
}

Expand Down

0 comments on commit aaa1c65

Please sign in to comment.