The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix: UXW-42 Debounce on the visualization resize is causing layout jumping (#62293)
Brad Andersonf9248c70ff1a
diff --git a/e2e/test/scenarios/visualizations-charts/combo.cy.spec.js b/e2e/test/scenarios/visualizations-charts/combo.cy.spec.jsindex 1038305741c..398ee619022 100644--- a/e2e/test/scenarios/visualizations-charts/combo.cy.spec.js+++ b/e2e/test/scenarios/visualizations-charts/combo.cy.spec.js@@ -78,6 +78,7 @@ describe("scenarios > visualizations > combo", () => {});H.openVizSettingsSidebar();+ H.ensureChartIsActive();cy.findByTestId("chartsettings-sidebar").within(() => {cy.findByText("Display").click();cy.findByText("Stack").click();diff --git a/frontend/src/metabase/common/components/DebouncedFrame/DebouncedFrame.jsx b/frontend/src/metabase/common/components/DebouncedFrame/DebouncedFrame.jsxindex 21b20e60949..920f2bd3192 100644--- a/frontend/src/metabase/common/components/DebouncedFrame/DebouncedFrame.jsx+++ b/frontend/src/metabase/common/components/DebouncedFrame/DebouncedFrame.jsx@@ -20,6 +20,11 @@ class DebouncedFrame extends Component {// There's probably a better way to block renders of children though_transition = false;+ // Used to trigger an immediate resize (without debounce/transition) without the need for remounting.+ // Useful if DebouncedFrame is resizing because of content loading in.+ // Will be set to true whenever `props.resetKey` changes.+ _queueImmediateResize = false;+static defaultProps = {enabled: true,};@@ -68,7 +73,19 @@ class DebouncedFrame extends Component {this._updateTransitionStyle();}- componentDidUpdate() {+ componentDidUpdate(prevProps) {+ if (prevProps.resetKey !== this.props.resetKey) {+ this._queueImmediateResize = true;+ }+ if (this._queueImmediateResize) {+ const { width, height } = this.props;+ if (width !== this.state.width || height !== this.state.height) {+ this.setState({ width, height });+ this._transition = false;+ this._queueImmediateResize = false;+ }+ }+this._updateTransitionStyle();}@@ -123,4 +140,7 @@ const DebouncedFrameForwardRef = forwardRef(},);-export default ExplicitSize()(DebouncedFrameForwardRef);+export default ExplicitSize({+ // Disable ExplicitSize's debounce/throttle since DebouncedFrame has a built-in debounce+ refreshMode: "none",+})(DebouncedFrameForwardRef);diff --git a/frontend/src/metabase/query_builder/components/view/View/ViewMainContainer/ViewMainContainer.tsx b/frontend/src/metabase/query_builder/components/view/View/ViewMainContainer/ViewMainContainer.tsxindex c77c94da28a..7d4ba1d7ff3 100644--- a/frontend/src/metabase/query_builder/components/view/View/ViewMainContainer/ViewMainContainer.tsx+++ b/frontend/src/metabase/query_builder/components/view/View/ViewMainContainer/ViewMainContainer.tsx@@ -137,6 +137,7 @@ export const ViewMainContainer = (props: ViewMainContainerProps) => {<DebouncedFrameclassName={ViewMainContainerS.StyledDebouncedFrame}enabled={!isLiveResizable}+ resetKey={props.isRunning}><QueryVisualization{...props}