Skip to content

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

Fix native transform editor results UI warts (#64081)

Romeo Van Snick5bd544baf5bb
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.module.css b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.module.css
index a27ea74c367..adb47fe6518 100644
--- a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.module.css
+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.module.css
@@ -1,4 +1,5 @@
.root {
display: flex;
border-bottom: 1px solid var(--mb-color-border);
+ border-top: 1px solid var(--mb-color-border);
}
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx
index c4612ccc76c..3e0b6c87ada 100644
--- a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx
@@ -1,5 +1,6 @@
import { useMemo, useState } from "react";
import { ResizableBox, type ResizableBoxProps } from "react-resizable";
+import { useWindowSize } from "react-use";
import type { CollectionPickerItem } from "metabase/common/components/Pickers/CollectionPicker";
import type { DataPickerItem } from "metabase/common/components/Pickers/DataPicker";
@@ -26,6 +27,9 @@ import S from "./EditorBody.module.css";
const EDITOR_HEIGHT = 550;
+const NATIVE_HEADER_HEIGHT = 55;
+const HEADER_HEIGHT = 65 + 50;
+
const NATIVE_EDITOR_SIDEBAR_FEATURES = {
dataReference: true,
snippets: true,
@@ -81,15 +85,18 @@ export function EditorBody({
const [isResizing, setIsResizing] = useState(false);
const reportTimezone = useSetting("report-timezone-long");
+ const editorHeight = useInitialEditorHeight(isNative);
+
const resizableBoxProps: Partial<ResizableBoxProps> = useMemo(
() => ({
- height: EDITOR_HEIGHT,
+ height: editorHeight,
resizeHandles: ["s"],
+ className: S.root,
style: isResizing ? undefined : { transition: "height 0.25s" },
onResizeStart: () => setIsResizing(true),
onResizeStop: () => setIsResizing(false),
}),
- [isResizing],
+ [isResizing, editorHeight],
);
const handleResize = () => {
@@ -143,9 +150,9 @@ export function EditorBody({
/>
) : (
<ResizableBox
- className={S.root}
axis="y"
- height={EDITOR_HEIGHT}
+ className={S.root}
+ height={editorHeight}
handle={<ResizeHandle />}
resizeHandles={["s"]}
onResizeStart={() => setIsResizing(true)}
@@ -208,3 +215,16 @@ function useDataPickerOptions({ databases }: { databases: ApiDatabase[] }) {
};
}, [databases]);
}
+
+function getHeaderHeight(isNative: boolean) {
+ if (isNative) {
+ return HEADER_HEIGHT + NATIVE_HEADER_HEIGHT;
+ }
+ return HEADER_HEIGHT;
+}
+
+function useInitialEditorHeight(isNative: boolean) {
+ const { height: windowHeight } = useWindowSize();
+ const headerHeight = getHeaderHeight(isNative);
+ return Math.min(0.8 * (windowHeight - headerHeight), EDITOR_HEIGHT);
+}