Skip to content

Conversation

@richardfogaca
Copy link
Contributor

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_TABLE reducer unconditionally sets activeSouthPaneTab when 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:

  1. addTable() function - Added optional expanded parameter (defaults to true)

    • Allows callers to specify whether the table should trigger tab switching
    • Maintains backward compatibility with default true value
  2. Autocomplete handler (useKeywords.ts) - Passes expanded: false

    • When user autocompletes a table name, explicitly passes false to prevent tab switching
    • Table is still added and appears in the left panel, but doesn't steal focus
  3. MERGE_TABLE reducer - Respect expanded parameter for new tables

    • Only sets activeSouthPaneTab when at.expanded === true
    • Manual table selection still auto-switches tabs (expected behavior)
    • Autocompleted tables don't switch tabs (fixed behavior)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Autocompleting "channels" keeps "bart_lines Data preview" active; channels table is added but collapsed.
Screenshot 2025-11-04 at 21 18 44

TESTING INSTRUCTIONS

  1. Open SQL Lab
  2. Select a table from the left panel (e.g., "bart_lines")
  3. Click the "Data preview" tab to view the table's data
  4. In the query editor, type "SELECT * FROM chann" and autocomplete to "SELECT * FROM channels"
  5. Verify: The "bart_lines Data preview" tab remains active
  6. Verify: The "channels" table appears in the left panel (collapsed, not expanded)
  7. Also verify: Manually selecting a table from the left panel still auto-expands it and switches to its tab (this is expected behavior and should not change)

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Nov 5, 2025

Code Review Agent Run #0158ed

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: c267f36..c267f36
    • superset-frontend/src/SqlLab/actions/sqlLab.js
    • superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts
    • superset-frontend/src/SqlLab/reducers/sqlLab.js
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added change:frontend Requires changing the frontend sqllab Namespace | Anything related to the SQL Lab labels Nov 5, 2025
@richardfogaca richardfogaca changed the title fix(sqllab): prevent unwanted tab switching when autocompleting table… fix(sqllab): prevent unwanted tab switching when autocompleting table names on SQL Lab Nov 5, 2025
Copy link

@korbit-ai korbit-ai bot left a 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
Performance 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.

Loving Korbit!? Share us on LinkedIn Reddit and X

Copy link
Contributor

Copilot AI left a 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 expanded parameter to the addTable action (defaults to true for backward compatibility)
  • Modified the reducer to only set activeSouthPaneTab when the table is expanded
  • Autocomplete now passes false for the expanded parameter 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

Comment on lines +226 to +228
if (at.expanded) {
newState.activeSouthPaneTab = at.id;
}
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend size/XS sqllab Namespace | Anything related to the SQL Lab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant