You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2023/08/10 16:16:36 UTC
[superset] 02/10: fix(explore): double resize triggered (#24886)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 42451880a8c92ab3980b7cfa181ee5805b61b903
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Tue Aug 8 10:21:21 2023 -0700
fix(explore): double resize triggered (#24886)
(cherry picked from commit 340bfd88ae4648cc3fec6edc288040edd219950b)
---
.../src/dashboard/components/gridComponents/Chart.jsx | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx
index 1c4d0dd956..a99061c707 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx
@@ -20,7 +20,7 @@ import cx from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { styled, t, logging } from '@superset-ui/core';
-import { isEqual } from 'lodash';
+import { debounce, isEqual } from 'lodash';
import { withRouter } from 'react-router-dom';
import { exportChart, mountExploreUrl } from 'src/explore/exploreUtils';
@@ -95,7 +95,7 @@ const defaultProps = {
// we use state + shouldComponentUpdate() logic to prevent perf-wrecking
// resizing across all slices on a dashboard on every update
-const RESIZE_TIMEOUT = 350;
+const RESIZE_TIMEOUT = 500;
const SHOULD_UPDATE_ON_PROP_CHANGES = Object.keys(propTypes).filter(
prop =>
prop !== 'width' && prop !== 'height' && prop !== 'isComponentVisible',
@@ -142,7 +142,7 @@ class Chart extends React.Component {
this.exportXLSX = this.exportXLSX.bind(this);
this.exportFullXLSX = this.exportFullXLSX.bind(this);
this.forceRefresh = this.forceRefresh.bind(this);
- this.resize = this.resize.bind(this);
+ this.resize = debounce(this.resize.bind(this), RESIZE_TIMEOUT);
this.setDescriptionRef = this.setDescriptionRef.bind(this);
this.setHeaderRef = this.setHeaderRef.bind(this);
this.getChartHeight = this.getChartHeight.bind(this);
@@ -178,8 +178,7 @@ class Chart extends React.Component {
}
if (nextProps.isFullSize !== this.props.isFullSize) {
- clearTimeout(this.resizeTimeout);
- this.resizeTimeout = setTimeout(this.resize, RESIZE_TIMEOUT);
+ this.resize();
return false;
}
@@ -189,8 +188,7 @@ class Chart extends React.Component {
nextProps.width !== this.state.width ||
nextProps.height !== this.state.height
) {
- clearTimeout(this.resizeTimeout);
- this.resizeTimeout = setTimeout(this.resize, RESIZE_TIMEOUT);
+ this.resize();
}
for (let i = 0; i < SHOULD_UPDATE_ON_PROP_CHANGES.length; i += 1) {
@@ -224,7 +222,7 @@ class Chart extends React.Component {
}
componentWillUnmount() {
- clearTimeout(this.resizeTimeout);
+ this.resize.cancel();
}
componentDidUpdate(prevProps) {