Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix SQL editor scrolling on Transform pages (#68107)

Anderson26f71cfeb54a
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.module.css b/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.module.css
new file mode 100644
index 00000000000..3796439464f
--- /dev/null
+++ b/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.module.css
@@ -0,0 +1,6 @@
+.editorBodyWrapper {
+ height: 100%;
+ min-height: 0;
+ overflow: auto;
+ width: 100%;
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.tsx b/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.tsx
index cdbbf476527..911d3de9d3e 100644
--- a/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/transforms-python/components/PythonTransformEditor/PythonTransformEditor.tsx
@@ -13,6 +13,7 @@ import { isPythonTransformSource } from "../../utils";
import { PythonDataPicker } from "./PythonDataPicker";
import { PythonEditorBody } from "./PythonEditorBody";
import { PythonEditorResults } from "./PythonEditorResults";
+import S from "./PythonTransformEditor.module.css";
import { PythonTransformTopBar } from "./PythonTransformTopBar";
import { useTestPythonTransform } from "./hooks";
import { updateTransformSignature } from "./utils";
@@ -88,7 +89,7 @@ export function PythonTransformEditor({
transformId={transformId}
onDatabaseChange={handleDatabaseChange}
/>
- <Flex h="100%" w="100%" style={{ minHeight: 0 }}>
+ <Flex className={S.editorBodyWrapper}>
{isEditMode && (
<PythonDataPicker
database={source["source-database"]}
diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.module.css b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.module.css
index 3b24129a18a..2b83734cc29 100644
--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.module.css
+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.module.css
@@ -1,10 +1,14 @@
.queryEditor {
- width: 100%;
background-color: var(--mb-color-background-secondary);
+ display: flex;
+ flex-direction: column;
+ width: 100%;
}
.editorWrapper {
+ overflow: auto;
width: 100%;
+ height: 100%;
}
.resizableArea {
@@ -19,3 +23,7 @@
are several template tags */
height: 3rem;
}
+
+.readOnlyEditor {
+ overflow: auto;
+}
diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx
index a8e1309aab1..0acdd06a41c 100644
--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx
+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx
@@ -275,7 +275,7 @@ export const NativeQueryEditor = forwardRef<
return (
<div
- className={cx(S.queryEditor, className)}
+ className={cx(S.queryEditor, className, { [S.readOnlyEditor]: readOnly })}
data-testid="native-query-editor-container"
ref={ref}
>
@@ -342,7 +342,13 @@ export const NativeQueryEditor = forwardRef<
onFormatQuery={handleFormatQuery}
/>
- <Stack m="1rem" gap="md" mt="auto">
+ <Stack
+ bottom="0.75rem"
+ display={readOnly ? "none" : undefined}
+ gap="md"
+ left="0.75rem"
+ pos="absolute"
+ >
{proposedQuestion && onRejectProposed && onAcceptProposed && (
<>
<Tooltip label={t`Accept proposed changes`} position="top">
diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/ResizableArea/ResizableArea.tsx b/frontend/src/metabase/query_builder/components/NativeQueryEditor/ResizableArea/ResizableArea.tsx
index 5c0386c0ab3..412e61e3c63 100644
--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/ResizableArea/ResizableArea.tsx
+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/ResizableArea/ResizableArea.tsx
@@ -34,10 +34,14 @@ export function ResizableArea(props: {
const resize = useCallback(
(height: number) => {
+ if (!resizable) {
+ return;
+ }
+
onResize?.(height);
setHeight(height);
},
- [onResize],
+ [onResize, resizable],
);
const handleResize = useCallback(
@@ -64,11 +68,19 @@ export function ResizableArea(props: {
setHeight(initialHeight);
}
- const dragHandle = resizable ? (
+ const dragHandle = (
<div className={S.dragHandleContainer} data-testid="drag-handle">
<div className={S.dragHandle} />
</div>
- ) : null;
+ );
+
+ if (!resizable) {
+ return (
+ <Flex w="100%" flex="1" h="100%" className={className}>
+ {children}
+ </Flex>
+ );
+ }
return (
<Resizable
diff --git a/frontend/src/metabase/query_builder/components/RunButton.tsx b/frontend/src/metabase/query_builder/components/RunButton.tsx
index ccd812fdae4..ebf2f30c113 100644
--- a/frontend/src/metabase/query_builder/components/RunButton.tsx
+++ b/frontend/src/metabase/query_builder/components/RunButton.tsx
@@ -50,6 +50,7 @@ const RunButton = forwardRef(function RunButton(
}}
icon={icon}
primary={isDirty}
+ white={!isDirty}
data-testid="run-button"
aria-label={ariaLabel}
onClick={isRunning ? onCancel : onRun}
diff --git a/frontend/src/metabase/query_builder/components/dataref/DatabasePane.tsx b/frontend/src/metabase/query_builder/components/dataref/DatabasePane.tsx
index 3b70e17b2e8..7d13d848d2f 100644
--- a/frontend/src/metabase/query_builder/components/dataref/DatabasePane.tsx
+++ b/frontend/src/metabase/query_builder/components/dataref/DatabasePane.tsx
@@ -15,6 +15,7 @@ import type {
ITreeNodeItem,
TreeNodeProps,
} from "metabase/common/components/tree/types";
+import CS from "metabase/css/core/index.css";
import SidebarContent from "metabase/query_builder/components/SidebarContent";
import type Database from "metabase-lib/v1/metadata/Database";
import type {
@@ -280,7 +281,11 @@ export const DatabasePane = ({
);
return (
- <LoadingAndErrorWrapper loading={isLoading} error={error}>
+ <LoadingAndErrorWrapper
+ loading={isLoading}
+ error={error}
+ className={CS.fullHeight}
+ >
<SidebarContent
title={databaseData?.name ?? "Untitled Database"}
icon={"database"}
diff --git a/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.module.css b/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.module.css
index ba0d4032121..41ba9d66b30 100644
--- a/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.module.css
+++ b/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.module.css
@@ -1,8 +1,16 @@
.queryResizableBox {
- display: flex;
border-bottom: 1px solid var(--mb-color-border);
+ display: flex;
+ max-height: 100%;
}
.nativeQueryEditor {
border-bottom: 1px solid var(--mb-color-border);
+ max-height: 100%;
+ overflow: hidden;
+
+ &.readOnly {
+ border-bottom: none;
+ height: 100%;
+ }
}
diff --git a/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.tsx b/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.tsx
index 173f69d8a2d..a3394a377f4 100644
--- a/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.tsx
+++ b/frontend/src/metabase/querying/editor/components/QueryEditor/QueryEditorBody/QueryEditorBody.tsx
@@ -1,3 +1,4 @@
+import cx from "classnames";
import { type ReactNode, useMemo, useState } from "react";
import { ResizableBox } from "react-resizable";
import { useWindowSize } from "react-use";
@@ -130,7 +131,9 @@ export function QueryEditorBody({
return (
<NativeQueryEditor
- className={S.nativeQueryEditor}
+ className={cx(S.nativeQueryEditor, {
+ [S.readOnly]: readOnly,
+ })}
availableHeight={availableHeight}
question={question}
proposedQuestion={proposedQuestion}
@@ -165,6 +168,7 @@ export function QueryEditorBody({
onRejectProposed={onRejectProposed}
topBarInnerContent={topBarInnerContent}
extraButton={extraButton}
+ resizable={!readOnly}
/>
);
}