Skip to content

Commit f2f97e3

Browse files
authored
fix(TextArea): ResizeObserver loop completed with undelivered notifications (#4582)
Motivation https://dnb-it.slack.com/archives/CMXABCHEY/p1739800350978059
1 parent c3571f6 commit f2f97e3

File tree

1 file changed

+8
-1
lines changed
  • packages/dnb-eufemia/src/components/textarea

1 file changed

+8
-1
lines changed

packages/dnb-eufemia/src/components/textarea/Textarea.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@ export default class Textarea extends React.PureComponent {
247247
if (isTrue(props.autoresize) && typeof window !== 'undefined') {
248248
this.setAutosize()
249249
try {
250-
this.resizeObserver = new ResizeObserver(this.setAutosize)
250+
this.resizeObserver = new ResizeObserver((entries) => {
251+
window.requestAnimationFrame(() => {
252+
if (!Array.isArray(entries) || !entries.length) {
253+
return
254+
}
255+
this.setAutosize()
256+
})
257+
})
251258
this.resizeObserver.observe(document.body)
252259
} catch (e) {
253260
window.addEventListener('resize', this.setAutosize)

0 commit comments

Comments
 (0)