Skip to content

Commit 566db3b

Browse files
committed
fix(QueryEditor): collapse bottom panel if empty
1 parent 5ee0705 commit 566db3b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/containers/Tenant/QueryEditor/QueryEditor.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ const initialTenantCommonInfoState = {
9191
function QueryEditor(props) {
9292
const [resultType, setResultType] = useState(RESULT_TYPES.EXECUTE);
9393

94+
const [isResultLoaded, setIsResultLoaded] = useState(false);
95+
9496
const [resultVisibilityState, dispatchResultVisibilityState] = useReducer(
9597
paneVisibilityToggleReducerCreator(DEFAULT_IS_QUERY_RESULT_COLLAPSED),
9698
initialTenantCommonInfoState,
@@ -117,11 +119,12 @@ function QueryEditor(props) {
117119
}, []);
118120

119121
useEffect(() => {
120-
const {showPreview} = props;
121-
if (showPreview && resultVisibilityState.collapsed) {
122+
if (props.showPreview || isResultLoaded) {
122123
dispatchResultVisibilityState(PaneVisibilityActionTypes.triggerExpand);
124+
} else {
125+
dispatchResultVisibilityState(PaneVisibilityActionTypes.triggerCollapse);
123126
}
124-
}, [props.showPreview, resultVisibilityState.collapsed]);
127+
}, [props.showPreview, isResultLoaded]);
125128

126129
useEffect(() => {
127130
const {
@@ -254,6 +257,7 @@ function QueryEditor(props) {
254257

255258
setResultType(RESULT_TYPES.EXECUTE);
256259
sendQuery({query: input, database: path, action: runAction});
260+
setIsResultLoaded(true);
257261
setShowPreview(false);
258262

259263
const {queries, currentIndex} = history;
@@ -272,6 +276,7 @@ function QueryEditor(props) {
272276
} = props;
273277
setResultType(RESULT_TYPES.EXPLAIN);
274278
getExplainQuery({query: input, database: path});
279+
setIsResultLoaded(true);
275280
setShowPreview(false);
276281
dispatchResultVisibilityState(PaneVisibilityActionTypes.triggerExpand);
277282
};

0 commit comments

Comments
 (0)