diff --git a/src/components/grid/CellViewerModal.tsx b/src/components/grid/CellViewerModal.tsx index f4265a9..8555241 100644 --- a/src/components/grid/CellViewerModal.tsx +++ b/src/components/grid/CellViewerModal.tsx @@ -236,43 +236,43 @@ export function CellViewerModal({ )}
-
- {isNullValue - ? ( -
- NULL -
- ) - : ( - { - if (isEditable) { - setDraftContent(value ?? ""); - } - }} - onMount={onMount} - theme={theme === "dark" ? "vs-dark" : "vs"} - options={{ - readOnly: !isEditable, - domReadOnly: !isEditable, - minimap: { enabled: false }, - lineNumbers: "on", - scrollBeyondLastLine: false, - wordWrap: "on", - renderWhitespace: "selection", - folding: true, - fontSize: 12, - automaticLayout: true, - padding: { top: 8, bottom: 8 }, - smoothScrolling: true, - renderLineHighlightOnlyWhenFocus: true, - }} - /> - )} -
+ {isNullValue + ? ( +
+ NULL +
+ ) + : ( + { + if (isEditable) { + setDraftContent(value ?? ""); + } + }} + onMount={onMount} + theme={theme === "dark" ? "vs-dark" : "vs"} + options={{ + readOnly: !isEditable, + domReadOnly: !isEditable, + minimap: { enabled: false }, + lineNumbers: "on", + scrollBeyondLastLine: false, + wordWrap: "on", + renderWhitespace: "selection", + folding: true, + fontSize: 12, + automaticLayout: true, + padding: { top: 8, bottom: 8 }, + smoothScrolling: true, + renderLineHighlightOnlyWhenFocus: true, + }} + /> + )}
diff --git a/src/components/grid/__tests__/CellViewerModal.test.tsx b/src/components/grid/__tests__/CellViewerModal.test.tsx index 9b63b21..2ea883f 100644 --- a/src/components/grid/__tests__/CellViewerModal.test.tsx +++ b/src/components/grid/__tests__/CellViewerModal.test.tsx @@ -4,7 +4,11 @@ import { CellViewerModal } from "../CellViewerModal"; vi.mock("@monaco-editor/react", () => ({ __esModule: true, - default: vi.fn(() =>
Monaco Editor
), + default: vi.fn(({ className }: { className?: string }) => ( +
+ Monaco Editor +
+ )), })); vi.mock("sql-formatter", () => ({ @@ -137,6 +141,41 @@ describe("CellViewerModal", () => { expect(screen.getByTestId("monaco-editor")).toBeInTheDocument(); }); + it("applies full-size layout classes to Monaco editor wrapper (#217)", () => { + render(); + const editor = screen.getByTestId("monaco-editor"); + expect(editor.className).toMatch(/\bh-full\b/); + expect(editor.className).toMatch(/\bw-full\b/); + expect(editor.className).toMatch(/\boverflow-hidden\b/); + }); + + it("does not nest Monaco inside an extra overflow-hidden wrapper (#217)", () => { + const { container } = render( + , + ); + const editor = screen.getByTestId("monaco-editor"); + const contentWrapper = container.querySelector(".min-h-0.flex-1.p-4"); + expect(contentWrapper).not.toBeNull(); + expect(contentWrapper?.firstElementChild).toBe(editor); + }); + + it("remounts Monaco editor when content length changes (#217)", async () => { + const { rerender } = render( + , + ); + const { default: MockedEditor } = await import("@monaco-editor/react"); + const firstCalls = (MockedEditor as unknown as { mock: { calls: unknown[][] } }) + .mock.calls.length; + rerender( + , + ); + const secondCalls = (MockedEditor as unknown as { mock: { calls: unknown[][] } }) + .mock.calls.length; + expect(secondCalls).toBeGreaterThan(firstCalls); + }); + it("shows search input when content length > 500", () => { const longContent = "x".repeat(501); render();