From 329b540b7d8f10a13cd86efe17448ae020faeb25 Mon Sep 17 00:00:00 2001
From: "Mahatthana (Kelvin) Nomsawadi" <mahatthana.n@gmail.com>
Date: Fri, 18 Mar 2022 12:01:52 +0700
Subject: [PATCH] Fix regression from fixing #20954 (#21051)

* Fix a regression from fixing #20228

* Reorder code order to make it easier to reason about.
---
 .../src/metabase/components/DebouncedFrame.jsx   | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/frontend/src/metabase/components/DebouncedFrame.jsx b/frontend/src/metabase/components/DebouncedFrame.jsx
index 85de80bcc1b..c09710b6724 100644
--- a/frontend/src/metabase/components/DebouncedFrame.jsx
+++ b/frontend/src/metabase/components/DebouncedFrame.jsx
@@ -32,12 +32,18 @@ export default class DebouncedFrame extends React.Component {
     };
   }
 
-  setSize = (width, height) => {
+  updateSize = () => {
     this._transition = false;
-    this.setState({ width, height }, this._updateTransitionStyle);
+
+    const { width, height } = this.props;
+    if (width !== this.state.width || height !== this.state.height) {
+      this.setState({ width, height }, this._updateTransitionStyle);
+    } else {
+      this._updateTransitionStyle();
+    }
   };
 
-  setSizeDebounced = _.debounce(this.setSize, DEBOUNCE_PERIOD);
+  updateSizeDebounced = _.debounce(this.updateSize, DEBOUNCE_PERIOD);
 
   UNSAFE_componentWillReceiveProps(nextProps) {
     if (!nextProps.enabled) {
@@ -49,11 +55,11 @@ export default class DebouncedFrame extends React.Component {
       this.state.height !== nextProps.height
     ) {
       if (this.state.width == null || this.state.height == null) {
-        this.setSizeDebounced(nextProps.width, nextProps.height);
+        this.updateSizeDebounced();
       } else {
-        this.setSizeDebounced(nextProps.width, nextProps.height);
         this._transition = true;
         this._updateTransitionStyle();
+        this.updateSizeDebounced();
       }
     }
   }
-- 
GitLab