From e3cab888f66a8003b2cd886a97b995e94196a948 Mon Sep 17 00:00:00 2001 From: Ryan Meyer Date: Mon, 11 Mar 2024 12:02:21 -0400 Subject: [PATCH] Debounce the ResizeObserver for automatic dialog resizing to resolve https://github.com/TeselaGen/tg-oss/issues/63 --- packages/ui/src/ResizableDraggableDialog/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/ResizableDraggableDialog/index.js b/packages/ui/src/ResizableDraggableDialog/index.js index 42add248..1c6ee440 100644 --- a/packages/ui/src/ResizableDraggableDialog/index.js +++ b/packages/ui/src/ResizableDraggableDialog/index.js @@ -1,6 +1,7 @@ import React from "react"; import { Dialog, Classes } from "@blueprintjs/core"; import { Rnd } from "react-rnd"; +import { debounce } from "lodash"; import "./style.css"; const defaultDialogWidth = 400; @@ -13,9 +14,11 @@ export default class ResizableDraggableDialog extends React.Component { this.setDefaults(); try { const el = this.containerEl.querySelector(".bp3-dialog-body"); - this.resizeObs = new ResizeObserver(() => { - this.setDefaults({ doNotSetXOrWidth: true }); - }); + this.resizeObs = new ResizeObserver( + debounce(() => { + this.setDefaults({ doNotSetXOrWidth: true }); + }) + ); this.resizeObs.observe(el); } catch (e) { console.warn(