Skip to content

Commit

Permalink
Debounce the ResizeObserver for automatic dialog resizing to resolve T…
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-stackwave committed Mar 11, 2024
1 parent 0666bb9 commit e3cab88
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/ui/src/ResizableDraggableDialog/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(
Expand Down

0 comments on commit e3cab88

Please sign in to comment.