Skip to content

Issue #13 - [BUG] Copy link to clipboard fails when opening saved query in SQL Lab #39

@rogelio-cmj

Description

@rogelio-cmj

Current Behavior

When a user opens a saved query in SQL Lab, the application attempts to copy the query link to the clipboard but immediately redirects to the SQL Lab page. Due to the asynchronous nature of the clipboard API and the immediate page navigation, the copy operation frequently fails to complete before the page unloads. Users receive no feedback about whether the copy succeeded or failed, and the link is not actually copied to their clipboard.

Reproduction Steps:

  1. Navigate to the Saved Queries list page in Superset
  2. Click on any saved query to open it in SQL Lab (either in the same window or a new window)
  3. Attempt to paste the clipboard contents into another application
  4. Observe: The clipboard either contains old content or the copy operation never completed, and no user feedback was provided about the copy status

Expected Behavior

When a user opens a saved query in SQL Lab, the application should first copy the query link to the clipboard and wait for the operation to complete before performing any navigation. The user should receive clear feedback about whether the copy operation succeeded or failed through toast notifications. Only after the clipboard operation completes (successfully or with an error) should the navigation to SQL Lab occur.

Acceptance Criteria:

  • The link to the saved query is successfully copied to the clipboard before any navigation occurs
  • A success toast notification displays "Link Copied!" when the clipboard operation succeeds
  • The navigation to SQL Lab (either same window or new window) only happens after the clipboard operation completes
  • The functionality works correctly for both opening in the same window and opening in a new window

Steps To Test

  1. Navigate to the Saved Queries list page in Superset
  2. Click on a saved query to open it in SQL Lab
  3. Verify that a toast notification appears indicating "Link Copied!"
  4. Open a text editor or another application and paste from the clipboard
  5. Confirm that the pasted content is a valid URL in the format: {origin}/sqllab?savedQueryId={id}
  6. Test opening a query in a new window (if applicable) and verify the same clipboard behavior
  7. If possible, test in a browser or environment where clipboard access is restricted and verify the error toast appears

Submission

Download https://cap.so/ to record your screen (use Studio mode). Export as an mp4, and drag and drop into an issue comment below.

Guide to submitting pull requests: https://hackmd.io/@timothy1ee/Hky8kV3hlx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions