From 62abc19308c0d8970db5ad2158fea2acb274ec6c Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Tue, 12 Jan 2021 12:32:02 -0800 Subject: [PATCH 1/3] fix (SQL Lab): disappearing results on tab switch --- .../src/SqlLab/components/SouthPane.jsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/SouthPane.jsx b/superset-frontend/src/SqlLab/components/SouthPane.jsx index 2d1db63bd0e4..e0589e5834fd 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane.jsx +++ b/superset-frontend/src/SqlLab/components/SouthPane.jsx @@ -90,20 +90,11 @@ export class SouthPane extends React.PureComponent { height: props.height, }; this.southPaneRef = React.createRef(); - this.getSouthPaneHeight = this.getSouthPaneHeight.bind(this); this.switchTab = this.switchTab.bind(this); } - UNSAFE_componentWillReceiveProps() { - // south pane expands the entire height of the tab content on mount - this.setState({ height: this.getSouthPaneHeight() }); - } - - // One layer of abstraction for easy spying in unit tests - getSouthPaneHeight() { - return this.southPaneRef.current - ? this.southPaneRef.current.clientHeight - : 0; + UNSAFE_componentWillReceiveProps(props) { + this.setState({ height: props.height }); } switchTab(id) { From 35b6b3ef32c624843a9bb4e88603dc835b36f14a Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Tue, 12 Jan 2021 16:42:57 -0800 Subject: [PATCH 2/3] Remove state --- superset-frontend/src/SqlLab/components/SouthPane.jsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/SouthPane.jsx b/superset-frontend/src/SqlLab/components/SouthPane.jsx index e0589e5834fd..bc711574c746 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane.jsx +++ b/superset-frontend/src/SqlLab/components/SouthPane.jsx @@ -86,17 +86,10 @@ const StyledPane = styled.div` export class SouthPane extends React.PureComponent { constructor(props) { super(props); - this.state = { - height: props.height, - }; this.southPaneRef = React.createRef(); this.switchTab = this.switchTab.bind(this); } - UNSAFE_componentWillReceiveProps(props) { - this.setState({ height: props.height }); - } - switchTab(id) { this.props.actions.setActiveSouthPaneTab(id); } @@ -112,7 +105,7 @@ export class SouthPane extends React.PureComponent { ); } - const innerTabContentHeight = this.state.height - TAB_HEIGHT; + const innerTabContentHeight = this.props.height - TAB_HEIGHT; let latestQuery; const { props } = this; if (props.editorQueries.length > 0) { From 1907dc221c44f6cf79baabcd23bf59301f1a860f Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Tue, 12 Jan 2021 17:23:03 -0800 Subject: [PATCH 3/3] Fix test --- .../spec/javascripts/sqllab/SouthPane_spec.jsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx b/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx index 6209b9617f75..02184863b81b 100644 --- a/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx +++ b/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx @@ -20,7 +20,7 @@ import React from 'react'; import configureStore from 'redux-mock-store'; import thunk from 'redux-thunk'; import { styledShallow as shallow } from 'spec/helpers/theming'; -import SouthPaneContainer, { SouthPane } from 'src/SqlLab/components/SouthPane'; +import SouthPaneContainer from 'src/SqlLab/components/SouthPane'; import ResultSet from 'src/SqlLab/components/ResultSet'; import { STATUS_OPTIONS } from 'src/SqlLab/constants'; import { initialState } from './fixtures'; @@ -80,12 +80,6 @@ describe('SouthPane', () => { let wrapper; - beforeAll(() => { - jest - .spyOn(SouthPane.prototype, 'getSouthPaneHeight') - .mockImplementation(() => 500); - }); - it('should render offline when the state is offline', () => { wrapper = getWrapper(); wrapper.setProps({ offline: true });