-
Notifications
You must be signed in to change notification settings - Fork 16.1k
fix(sqllab): prevent unwanted tab switching when autocompleting table names on SQL Lab #35992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(sqllab): prevent unwanted tab switching when autocompleting table names on SQL Lab #35992
Conversation
Code Review Agent Run #0158edActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Redundant computation elimination ▹ view |
Files scanned
| File Path | Reviewed |
|---|---|
| superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts | ✅ |
| superset-frontend/src/SqlLab/reducers/sqlLab.js | ✅ |
| superset-frontend/src/SqlLab/actions/sqlLab.js | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR prevents automatic tab switching when tables are added via autocomplete in SQL Lab. Instead of always switching to the newly added table's tab, the behavior is now conditional based on whether the table is expanded.
- Added an optional
expandedparameter to theaddTableaction (defaults totruefor backward compatibility) - Modified the reducer to only set
activeSouthPaneTabwhen the table is expanded - Autocomplete now passes
falsefor theexpandedparameter to prevent unwanted tab switches
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| superset-frontend/src/SqlLab/actions/sqlLab.js | Added optional expanded parameter to addTable function with default value of true |
| superset-frontend/src/SqlLab/reducers/sqlLab.js | Modified reducer to conditionally set activeSouthPaneTab only when table is expanded |
| superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts | Passes false for expanded parameter when adding tables via autocomplete |
| if (at.expanded) { | ||
| newState.activeSouthPaneTab = at.id; | ||
| } |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
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.
SUMMARY
Fixes unwanted tab switching in SQL Lab when autocompleting table names in the query editor.
Problem:
When viewing a table preview (e.g., "bart_lines Data preview") and autocompleting a table name in the SQL editor (e.g., "SELECT * FROM channels"), the UI automatically switches to the autocompleted table's "Columns" tab,
losing the current view.
Root Cause:
The
MERGE_TABLEreducer unconditionally setsactiveSouthPaneTabwhen adding new tables (line 229), regardless of whether the table was manually selected or added via autocomplete.Solution:
Three changes work together to prevent unwanted tab switching:
addTable()function - Added optionalexpandedparameter (defaults totrue)truevalueAutocomplete handler (
useKeywords.ts) - Passesexpanded: falsefalseto prevent tab switchingMERGE_TABLEreducer - Respectexpandedparameter for new tablesactiveSouthPaneTabwhenat.expanded === trueBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Autocompleting "channels" keeps "bart_lines Data preview" active; channels table is added but collapsed.

TESTING INSTRUCTIONS
ADDITIONAL INFORMATION