Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,12 +950,13 @@ export function mergeTable(table, query, prepend) {
return { type: MERGE_TABLE, table, query, prepend };
}

export function addTable(queryEditor, tableName, catalogName, schemaName) {
export function addTable(queryEditor, tableName, catalogName, schemaName, expanded = true) {
return function (dispatch, getState) {
const { dbId } = getUpToDateQuery(getState(), queryEditor, queryEditor.id);
const queryEditorId = queryEditor.tabViewId ?? queryEditor.id;
const table = {
dbId,
queryEditorId: queryEditor.tabViewId ?? queryEditor.id,
queryEditorId,
catalog: catalogName,
schema: schemaName,
name: tableName,
Expand All @@ -964,7 +965,7 @@ export function addTable(queryEditor, tableName, catalogName, schemaName) {
mergeTable({
...table,
id: nanoid(11),
expanded: true,
expanded,
}),
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export function useKeywords(
data.value,
catalog,
schema,
false, // Don't auto-expand/switch tabs when adding via autocomplete
),
);
}
Expand Down
4 changes: 3 additions & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ export default function sqlLabReducer(state = {}, action) {
// for new table, associate Id of query for data preview
at.dataPreviewQueryId = null;
let newState = addToArr(state, 'tables', at, Boolean(action.prepend));
newState.activeSouthPaneTab = at.id;
if (at.expanded) {
newState.activeSouthPaneTab = at.id;
}
Comment on lines +226 to +228
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for setting activeSouthPaneTab when at.expanded is true is now duplicated in two places within the same reducer case (lines 218-220 for existing tables and lines 226-228 for new tables). Consider extracting this logic to avoid duplication. For example: return { ...newState, ...(at.expanded && { activeSouthPaneTab: at.id }) }; at the end of the reducer case.

Copilot uses AI. Check for mistakes.
if (action.query) {
newState = alterInArr(newState, 'tables', at, {
dataPreviewQueryId: action.query.id,
Expand Down
Loading