Files
supabase/apps/studio/components
7ff3264b5f fix(studio): strip one-shot content param from SQL editor URL (#47140)
## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

When you open the SQL editor with prefilled SQL via
`/sql/new?content=<sql>`, the editor seeds its contents from the
`content` query param, then navigates to the newly created snippet with
`router.push`.

That leaves the (often very long) `/sql/new?content=...` URL in the
browser history. Pressing Back returns to that URL instead of the page
you came from. It is a wasted step, and it re-seeds and recreates a
fresh snippet.

This affects every entry point that opens the SQL editor with prefilled
SQL, such as the table definition "Open in SQL Editor" button, create
index, and the SQL command menu.

## What is the new behavior?

When the editor is seeded from a `content` deep link, the navigation to
the new snippet uses `router.replace` instead of `router.push`. This
collapses the one-shot `/sql/new?content=...` URL out of the history.

Back now returns straight to the page you came from, with no wasted step
and no duplicate snippet. Normal new query creation (no `content` param)
is unchanged.

## To test

1. Open any table in the Table Editor, switch to the Definition view,
and click "Open in SQL Editor". Any deep link with prefilled SQL works.
You can also visit `/project/<ref>/sql/new?content=SELECT%201` directly.
2. Confirm the SQL editor opens with the SQL prefilled, and the URL no
longer contains `?content=`.
3. Press the browser Back button.
4. You return straight to the previous page in a single Back.

Before this fix, the first Back landed on `/sql/new?content=...` and
recreated a snippet, and only a second Back reached the page you came
from.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved navigation behavior in SQL Editor when creating snippets from
imported content, resulting in more efficient routing.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-22 10:57:53 -06:00
..
2026-06-18 15:43:46 +01:00
2026-06-22 10:36:21 +02:00

Writing components

Where to create your components

  • For components that declare the general structure and layout of a page:
    • /components/layouts/xxx
  • For components that are tightly coupled to a specific interface:
    • /components/interfaces/xxx
  • For components that are meant to be reusable across multiple pages:
    • /components/ui/xxx
  • Note: We're gradually moving files out of the to-be-cleaned folder into the respective folders as we refactor

Component structure

  • If a component has constants and utility methods that are tightly coupled to itself, keep them close to the component and enclose them in a folder with an index.tsx as an entry point
  • Otherwise it can just be a file on its own
  • For example:
    • components/ui
      - SampleComponentA
        - SampleComponentA.tsx
        - SampleComponentA.constants.ts
        - SampleComponentA.utils.ts
        - SampleComponentA.types.ts
        - index.ts
      - SampleComponentB.tsx
      

Template for building components


// Declare the prop types of your component
interface ComponentAProps {
  sampleProp: string
}

// Name your component accordingly
const ComponentA = ({ sampleProp }: ComponentAProps) => {
  return <div>ComponentA: {sampleProp}</div>
}

export default ComponentA