Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(sql-editor): keep JIT request statement editor fixed-height (#20676)

Vincent Huanga89d8dfe101f
diff --git a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx
index 09fc87121a..509d688fab 100644
--- a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx
+++ b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx
@@ -293,12 +293,15 @@ vi.mock("@/react/components/monaco/MonacoEditor", () => ({
MonacoEditor: ({
content,
onChange,
+ autoHeight,
}: {
content: string;
onChange?: (val: string) => void;
+ autoHeight?: boolean;
}) => (
<textarea
data-testid="monaco-editor"
+ data-auto-height={String(autoHeight)}
value={content}
onChange={(e) => onChange?.(e.target.value)}
/>
@@ -381,6 +384,31 @@ describe("AccessGrantRequestDrawer", () => {
unmount();
});
+ test("statement editor is fixed-height (autoHeight=false) so a long query can't overflow and cover the reason box", () => {
+ const onClose = vi.fn();
+ // A tall statement is what triggered the bug: MonacoEditor's default
+ // autoHeight grows the editor to its content (clamped to 600px), overflowing
+ // the 160px (h-40) wrapper and painting over the fields below it — hiding the
+ // reason box. The fix pins autoHeight={false} so it stays a fixed, internally
+ // scrolling box. jsdom has no layout engine, so we assert the prop contract.
+ const { container, render, unmount } = renderIntoContainer(
+ <AccessGrantRequestDrawer
+ targets={["instances/inst1/databases/mydb"]}
+ query={"SELECT id,\n".repeat(40) + "FROM orders"}
+ onClose={onClose}
+ />
+ );
+ render();
+
+ const monacoEditor = container.querySelector(
+ "[data-testid='monaco-editor']"
+ ) as HTMLTextAreaElement;
+ expect(monacoEditor).not.toBeNull();
+ expect(monacoEditor.getAttribute("data-auto-height")).toBe("false");
+
+ unmount();
+ });
+
test("Submit button disabled when required fields missing", () => {
const onClose = vi.fn();
const { container, render, unmount } = renderIntoContainer(
diff --git a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
index 6590c7cfa2..9c292fb8e2 100644
--- a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
+++ b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
@@ -369,6 +369,14 @@ function AccessGrantRequestDrawerInner({
description={t("sql-editor.only-select-allowed")}
/>
<MonacoEditor
+ // Fixed-height box: fill the h-40 wrapper and scroll internally.
+ // MonacoEditor defaults to autoHeight, which sizes the editor to
+ // its content (clamped to 600px). A long statement then overflows
+ // the 160px wrapper (which doesn't clip) and paints over the
+ // fields below it — Unmask/Export/Expiration/Reason — hiding the
+ // reason box. autoHeight={false} keeps it a fixed, internally
+ // scrolling box, matching every other fixed-height embed.
+ autoHeight={false}
// Drawer Monaco portals outside `.sqleditor--wrapper`, so opt the
// canvas into the transparent-background rule and back it with the
// themed `bg-background` (from `sheetStyle`'s `--color-background`)