richardfogaca opened a new pull request, #35992:
URL: https://github.com/apache/superset/pull/35992
### 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.
<img width="999" height="523" alt="Screenshot 2025-11-04 at 21 18 44"
src="https://github.com/user-attachments/assets/c63824d5-37ea-4484-99c8-5f4cbcff5705"
/>
### 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:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]