Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): fix GraphiQL editor layout, gutter bleed and spacing (#47334)

Alaister Young5c0b6279045f
diff --git a/apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx b/apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx
index e6525e61d85..6c761321c57 100644
--- a/apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx
+++ b/apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx
@@ -8,7 +8,7 @@ import { useParams } from 'common'
import { GraphiQL, HISTORY_PLUGIN } from 'graphiql'
import { User as IconUser } from 'lucide-react'
import { useTheme } from 'next-themes'
-import { useCallback, useEffect, useMemo, useState } from 'react'
+import { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from 'react'
import { toast } from 'sonner'
import { LogoLoader } from 'ui'
@@ -59,7 +59,51 @@ const GraphiQLMonacoTheme = ({ resolvedTheme }: { resolvedTheme: 'dark' | 'light
return null
}
+/**
+ * Inset the editor content from the container edges without floating the scroll shadow.
+ *
+ * Monaco anchors its `.scroll-decoration` (the shadow shown when scrolled) to the editor's
+ * top edge and absolutely positions the line numbers at the gutter's left edge, so container
+ * padding can't move either — it would just push the whole editor (shadow included) inward.
+ * Instead use Monaco's own options:
+ * - `padding` insets the content top/bottom while leaving the shadow pinned to the top, so
+ * `.graphiql-query-editor` can stay full-bleed (`p-0`) for a flush shadow.
+ * - `glyphMargin` reserves an empty column to the left of the line numbers (same gutter
+ * background), giving them left breathing room.
+ *
+ * GraphiQL shares the global Monaco instance with the rest of Studio (the SQL editor etc.),
+ * so we must scope `updateOptions` to editors that live inside the GraphiQL container —
+ * `monaco.editor.getEditors()`/`onDidCreateEditor()` see every editor in the app, and
+ * applying these options globally would shift the SQL editor's layout too. Filtering by
+ * container also means there's nothing to revert on unmount: we never touch other editors.
+ */
+const GraphiQLEditorOptions = ({
+ containerRef,
+}: {
+ containerRef: RefObject<HTMLDivElement | null>
+}) => {
+ const { monaco } = useMonaco()
+
+ useEffect(() => {
+ if (!monaco) return
+ const options = { padding: { top: 16, bottom: 16 }, glyphMargin: true }
+ const applyToGraphiQLEditor = (editor: ReturnType<typeof monaco.editor.getEditors>[number]) => {
+ if (containerRef.current?.contains(editor.getContainerDomNode())) {
+ editor.updateOptions(options)
+ }
+ }
+
+ monaco.editor.getEditors().forEach(applyToGraphiQLEditor)
+ const disposable = monaco.editor.onDidCreateEditor(applyToGraphiQLEditor)
+
+ return () => disposable.dispose()
+ }, [monaco, containerRef])
+
+ return null
+}
+
export const GraphiQLTab = () => {
+ const editorContainerRef = useRef<HTMLDivElement>(null)
const { resolvedTheme } = useTheme()
const { ref: projectRef } = useParams()
const currentTheme = resolvedTheme?.includes('dark') ? 'dark' : 'light'
@@ -145,6 +189,7 @@ export const GraphiQLTab = () => {
return (
<div className="flex flex-col h-full">
<GraphiQLMonacoTheme resolvedTheme={currentTheme} />
+ <GraphiQLEditorOptions containerRef={editorContainerRef} />
{notice === 'opt-in' && (
<IntrospectionDisabledNotice
schema={DEFAULT_INTROSPECTION_SCHEMA}
@@ -159,7 +204,7 @@ export const GraphiQLTab = () => {
onDisabled={handleIntrospectionChanged}
/>
)}
- <div className="flex-1 min-h-0">
+ <div ref={editorContainerRef} className="flex-1 min-h-0">
<GraphiQL
key={graphiqlKey}
fetcher={fetcher}
diff --git a/apps/studio/components/interfaces/Integrations/GraphQL/graphiql.module.css b/apps/studio/components/interfaces/Integrations/GraphQL/graphiql.module.css
index ff28fedbefd..359b954498a 100644
--- a/apps/studio/components/interfaces/Integrations/GraphQL/graphiql.module.css
+++ b/apps/studio/components/interfaces/Integrations/GraphQL/graphiql.module.css
@@ -34,6 +34,27 @@
border-left: 0;
}
+/* Restore Monaco's intended clipping of the editor body. Monaco renders the gutter as an
+ * oversized, scroll-offset `.margin` (absolutely positioned, opaque background) and relies
+ * on `.overflow-guard { overflow: hidden }` to clip it to the editor box. Here the guard
+ * ends up `overflow: visible` via an inline style Monaco's layout sets at runtime, so the
+ * white gutter escapes the editor and paints over the page above it. An inline style beats
+ * any external selector regardless of specificity, so `!important` is required to win — it
+ * is not a specificity shortcut here. Scoped to `.root` so the SQL editor's Monaco is
+ * untouched. Autocomplete/hover popups live in `.overflowingContentWidgets` (a sibling of
+ * `.overflow-guard`), so they are not clipped. */
+.root :global(.monaco-editor .overflow-guard) {
+ @apply !overflow-hidden;
+}
+
+/* Drop GraphiQL's default 16px padding around the query editor so the editor sits flush to
+ * its container. This keeps Monaco's scroll shadow (`.scroll-decoration`, pinned to the
+ * editor's top edge) full-bleed instead of floating inset. The content's own breathing room
+ * is restored via Monaco's `padding`/`glyphMargin` options in GraphiQLTab.tsx. */
+.root :global(.graphiql-query-editor) {
+ @apply p-0;
+}
+
/* Lift the response panel above the editor surface so the two read as separate panes.
* The token differs per theme because the editor sits at a different baseline lightness
* in each (~12% L in dark, ~94% L in light), so a single surface token can't lift it
diff --git a/apps/studio/components/interfaces/Integrations/Integration/LegacyIntegrationPage.tsx b/apps/studio/components/interfaces/Integrations/Integration/LegacyIntegrationPage.tsx
index ac55db43495..8a75e488692 100644
--- a/apps/studio/components/interfaces/Integrations/Integration/LegacyIntegrationPage.tsx
+++ b/apps/studio/components/interfaces/Integrations/Integration/LegacyIntegrationPage.tsx
@@ -135,7 +135,7 @@ const LegacyIntegrationPage = () => {
)}
</PageHeader>
- <div className="mx-auto w-full">{content}</div>
+ <div className="flex-1 min-h-0 mx-auto w-full">{content}</div>
</>
)
}
diff --git a/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceDetail.tsx b/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceDetail.tsx
index 28a3f480a06..dc013378a55 100644
--- a/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceDetail.tsx
+++ b/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceDetail.tsx
@@ -175,7 +175,9 @@ export const MarketplaceDetail = () => {
<CustomPageComponent />
</div>
) : (
- <CustomPageComponent />
+ <div className="flex-1 min-h-0">
+ <CustomPageComponent />
+ </div>
)
) : null}
</>