Skip to content

fix(SqlLab): improve SQL diff modal — responsive width, padding, tabs, and copy button - #39246

Merged
mistercrunch merged 12 commits into
masterfrom
sql-popover-fix
Apr 10, 2026
Merged

mistercrunch merged 12 commits into
masterfrom
sql-popover-fix

Conversation

@mistercrunch

@mistercrunch mistercrunch commented Apr 9, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Fixes several UX issues with the Source SQL vs Executed SQL modal in SQL Lab (sc-102563):

  1. Responsive width — modal now scales to viewport width (max 900px) instead of fixed 600px
  2. Padding restored — removed a negative-margin hack that was stripping padding from labels and breaking vertical overflow/scrolling
  3. Tabs instead of stacked blocks — when Source SQL and Executed SQL differ, they're shown in separate tabs (defaulting to Executed SQL, since that's what ran). When identical, only a single "Source SQL" block is shown.
  4. Copy-to-clipboard button — added `showCopyButton` prop (default `true`) to `CodeSyntaxHighlighter` so every code block gets a copy icon overlay with checkmark feedback. Uses `navigator.clipboard?.writeText(...)?.then(...)` with full optional chaining so it's safe in environments without the Clipboard API (Jest, HTTP iframes). `SyntaxHighlighterCopy` (which already has its own toast-based copy) passes `showCopyButton={false}` to avoid duplicate controls.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: Fixed 600px wide, content overflowing vertically, "Source SQL" / "Executed SQL" labels flush against the edge, both blocks always stacked vertically.

Screenshot 2026-04-09 at 5 39 14 PM

After: Responsive width, proper padding, tabs for diff view, copy button on each code block.

Screenshot 2026-04-09 at 5 36 58 PM

TESTING INSTRUCTIONS

  1. Open SQL Lab and run a query that has a row limit applied (so `executedSql` differs from `sql`)
  2. Click the SQL preview in the results panel to open the modal
  3. Verify the modal is wider and scrolls properly for long queries
  4. Verify two tabs appear: "Executed SQL" (active by default) and "Source SQL"
  5. Verify the copy button appears in the top-right of each code block and copies to clipboard
  6. Run a query where source and executed SQL are identical — verify only one block is shown (no tabs)
  7. Open a Saved Queries preview modal — verify no duplicate copy buttons appear

ADDITIONAL INFORMATION

  • Changes UI
  • Has associated issue:
  • Required feature flags:
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

mistercrunch and others added 5 commits April 9, 2026 16:11
The Source SQL / Executed SQL modal in SQL Lab used the default 600px
width, making long SQL queries hard to read. Adding the `responsive`
prop makes the modal scale up to 900px and adapt to viewport size.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The modal body content had a negative margin (-sizeUnit*6 on all sides)
that was pulling content outside the scrollable area (breaking overflow)
and stripping padding from the Source/Executed SQL titles. Removing it
lets the modal body's built-in padding apply naturally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ngfully

When the only difference between Source SQL and Executed SQL is a trailing
LIMIT clause (applied by row limit enforcement), show a single block labeled
"Source SQL" — they're effectively the same query.

When the queries genuinely differ, show them in two tabs defaulting to
"Executed SQL" (what actually ran), with "Source SQL" as the second tab.
This avoids stacking two large code blocks vertically and makes the
relationship between the two clearer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a `showCopyButton` prop (default true) to CodeSyntaxHighlighter that
overlays a copy icon in the top-right corner of every code block. Uses
navigator.clipboard directly with a brief checkmark feedback state — no
external dependencies, fully self-contained in the package.

Disable the button on the HighlightedSql trigger node (the inline
truncated preview) where it makes no sense.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Guard navigator.clipboard with optional chaining to avoid crashes in
  environments where the Clipboard API is unavailable (Jest, HTTP iframes)
- Remove trailing-LIMIT stripping from the diff comparison: if a row limit
  was applied, users should see it in the Executed SQL tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dosubot dosubot Bot added change:frontend Requires changing the frontend sqllab Namespace | Anything related to the SQL Lab labels Apr 9, 2026
Comment thread superset-frontend/src/SqlLab/components/HighlightedSql/HighlightedSql.test.tsx Outdated
Comment thread superset-frontend/src/SqlLab/components/HighlightedSql/HighlightedSql.test.tsx Outdated
Comment thread superset-frontend/src/SqlLab/components/HighlightedSql/index.tsx
@codecov

codecov Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.38%. Comparing base (5815665) to head (939d1da).
⚠️ Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
...ontend/packages/superset-ui-core/src/utils/copy.ts 80.00% 8 Missing ⚠️

❌ Your project status has failed because the head coverage (99.81%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #39246   +/-   ##
=======================================
  Coverage   64.37%   64.38%           
=======================================
  Files        2550     2550           
  Lines      132180   132205   +25     
  Branches    30661    30672   +11     
=======================================
+ Hits        85096    85119   +23     
- Misses      45599    45601    +2     
  Partials     1485     1485           
Flag Coverage Δ
javascript 65.92% <87.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Agent Run #9f1ec8

Actionable Suggestions - 3
  • superset-frontend/src/SqlLab/components/HighlightedSql/HighlightedSql.test.tsx - 1
    • Missing test assertion for Source SQL tab · Line 50-63
  • superset-frontend/packages/superset-ui-core/src/components/CodeSyntaxHighlighter/index.tsx - 2
Review Details
  • Files reviewed - 3 · Commit Range: dfd6044..1590929
    • superset-frontend/packages/superset-ui-core/src/components/CodeSyntaxHighlighter/index.tsx
    • superset-frontend/src/SqlLab/components/HighlightedSql/HighlightedSql.test.tsx
    • superset-frontend/src/SqlLab/components/HighlightedSql/index.tsx
  • Files skipped - 0
  • Tools
    • 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 Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

…utton, test coverage

- Fix clipboard guard: chain ?.then() so undefined clipboard doesn't throw
- SyntaxHighlighterCopy already has its own copy button (with toasts via
  src/utils/copy); pass showCopyButton={false} to suppress the built-in
  one and avoid duplicate controls in query preview modals
- Add CodeSyntaxHighlighter tests: copy button shown/hidden, no-throw
  when clipboard API is unavailable
- Add HighlightedSql test: rawSql === sql shows single block with no tabs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #0e7731

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 1590929..b7ca630
    • superset-frontend/packages/superset-ui-core/src/components/CodeSyntaxHighlighter/index.test.tsx
    • superset-frontend/packages/superset-ui-core/src/components/CodeSyntaxHighlighter/index.tsx
    • superset-frontend/src/SqlLab/components/HighlightedSql/HighlightedSql.test.tsx
    • superset-frontend/src/features/queries/SyntaxHighlighterCopy.tsx
  • Files skipped - 0
  • Tools
    • 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 Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@sadpandajoe sadpandajoe added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Apr 10, 2026
@github-actions github-actions Bot added 🎪 b7ca630 🚦 building and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Apr 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for b7ca630

@github-actions github-actions Bot added 🎪 ⌛ 48h Environment expires after 48 hours (default) 🎪 b7ca630 🚦 deploying and removed 🎪 b7ca630 🚦 building labels Apr 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for 34f3b7b

• Environment: http://54.188.176.204:8080 (admin/admin)
• Lifetime: 48h auto-cleanup
• Updates: New commits create fresh environments automatically

@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for 366fe18

@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for 366fe18

• Environment: http://44.255.92.3:8080 (admin/admin)
• Lifetime: 48h auto-cleanup
• Updates: New commits create fresh environments automatically

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Agent Run #11699d

Actionable Suggestions - 1
  • superset-frontend/packages/superset-ui-core/src/utils/copy.ts - 1
Additional Suggestions - 4
  • superset-frontend/packages/superset-ui-core/src/utils/copy.ts - 4
    • Missing Explicit Return Type · Line 26-26
      Add explicit return type : Promise to copyTextWithClipboardApi for consistency with codebase standards.
      Code suggestion
       diff --git a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       index 0000000..0000000 100644
      --- a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
      +++ b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       @@ -26,1 +26,1 @@
      -const copyTextWithClipboardApi = async (getText: () => Promise<string>) => {
      +const copyTextWithClipboardApi = async (getText: () => Promise<string>): Promise<void> => {
    • Broad Exception Catch · Line 40-40
      Replace bare exception catch with specific catch (error: unknown) to avoid masking unexpected errors, per codebase standards.
      Code suggestion
       diff --git a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       index 0000000..0000000 100644
      --- a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
      +++ b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       @@ -40,1 +40,1 @@
      -    } catch {
      +    } catch (error: unknown) {
    • Missing Explicit Return Type · Line 55-55
      Add explicit return type : Promise to copyTextToClipboard for consistency with codebase standards.
      Code suggestion
       diff --git a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       index 0000000..0000000 100644
      --- a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
      +++ b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       @@ -55,1 +55,1 @@
      -const copyTextToClipboard = (getText: () => Promise<string>) =>
      +const copyTextToClipboard = (getText: () => Promise<string>): Promise<void> =>
    • Broad Exception Catch · Line 81-81
      Replace catch (err) with catch (error: unknown) in execCommand fallback to follow specific exception handling standards.
      Code suggestion
       diff --git a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       index 0000000..0000000 100644
      --- a/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
      +++ b/superset-frontend/packages/superset-ui-core/src/utils/copy.ts
       @@ -81,1 +81,1 @@
      -              } catch (err) {
      +              } catch (error: unknown) {
Review Details
  • Files reviewed - 6 · Commit Range: b7ca630..34f3b7b
    • superset-frontend/packages/superset-ui-core/src/components/CodeSyntaxHighlighter/index.test.tsx
    • superset-frontend/packages/superset-ui-core/src/components/CodeSyntaxHighlighter/index.tsx
    • superset-frontend/packages/superset-ui-core/src/utils/copy.ts
    • superset-frontend/packages/superset-ui-core/src/utils/index.ts
    • superset-frontend/src/utils/copy.ts
    • superset-frontend/src/SqlLab/components/HighlightedSql/HighlightedSql.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ 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 Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment on lines +36 to +38
const clipboardItem = new ClipboardItem({
'text/plain': getText(),
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Safari ClipboardItem API Misuse

For Safari, await getText() and pass its result as a Blob to ClipboardItem instead of passing the Promise directly.

Code Review Run #11699d


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Live binding re-exports (export { default } from '...') create
non-configurable properties that jest.spyOn cannot redefine. Use
import + export default instead so the binding is writable.

Fixes DataTablesPane test: 'Should copy data table content correctly'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for 939d1da

@bito-code-review

bito-code-review Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #6ea9e3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 34f3b7b..939d1da
    • superset-frontend/src/utils/copy.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ 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 Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tested it. works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels change:frontend Requires changing the frontend packages preset-io size/L sqllab Namespace | Anything related to the SQL Lab 🍒 6.1.0 Cherry-picked to 6.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants