Skip to content

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

Documents viz setting sidebar fixes (#81740)

Kevin Kelleherc8a894150897
diff --git a/frontend/src/metabase/documents/components/EmbedQuestionSettingsSidebar.tsx b/frontend/src/metabase/documents/components/EmbedQuestionSettingsSidebar.tsx
index d681f345486..c7e42c1a9a2 100644
--- a/frontend/src/metabase/documents/components/EmbedQuestionSettingsSidebar.tsx
+++ b/frontend/src/metabase/documents/components/EmbedQuestionSettingsSidebar.tsx
@@ -8,6 +8,7 @@ import {
ActionIcon,
Box,
Button,
+ Ellipsified,
Group,
Icon,
Loader,
@@ -130,9 +131,14 @@ export const EmbedQuestionSettingsSidebar = ({
return (
<Box className={S.container}>
<Box className={S.header}>
- <Group w="100%" justify="space-between" align="flex-start">
- <Group align="center" p="lg">
- <Text size="md" fw="bold">{t`Visualize as`}</Text>
+ <Group
+ w="100%"
+ wrap="nowrap"
+ justify="space-between"
+ align="flex-start"
+ >
+ <Group wrap="nowrap" miw={0} flex={1} align="center" p="lg">
+ <Text size="md" fw="bold" flex="none">{t`Visualize as`}</Text>
<Menu position="bottom-start">
<Menu.Target>
<Button
@@ -148,8 +154,9 @@ export const EmbedQuestionSettingsSidebar = ({
) : null
}
justify="space-between"
+ miw={0}
>
- {selectedElem?.label}
+ <Ellipsified>{selectedElem?.label}</Ellipsified>
</Button>
</Menu.Target>
<Menu.Dropdown>
diff --git a/frontend/src/metabase/documents/hooks/use-draft-card-operations.ts b/frontend/src/metabase/documents/hooks/use-draft-card-operations.ts
index dcf5e1e080f..cb71f64bed8 100644
--- a/frontend/src/metabase/documents/hooks/use-draft-card-operations.ts
+++ b/frontend/src/metabase/documents/hooks/use-draft-card-operations.ts
@@ -46,11 +46,13 @@ export function useDraftCardOperations(
};
dispatch(
- datasetApi.util.upsertQueryData(
- "getAdhocQuery",
- draftQueryArgs,
- regularDataset,
- ),
+ datasetApi.util.upsertQueryEntries([
+ {
+ endpointName: "getAdhocQuery",
+ arg: draftQueryArgs,
+ value: regularDataset,
+ },
+ ]),
);
}
diff --git a/frontend/src/metabase/documents/hooks/use-draft-card-operations.unit.spec.ts b/frontend/src/metabase/documents/hooks/use-draft-card-operations.unit.spec.ts
new file mode 100644
index 00000000000..4f9804429e5
--- /dev/null
+++ b/frontend/src/metabase/documents/hooks/use-draft-card-operations.unit.spec.ts
@@ -0,0 +1,41 @@
+import { act, renderHookWithProviders } from "__support__/ui";
+import { datasetApi } from "metabase/api/dataset";
+import { createMockCard, createMockDataset } from "metabase-types/api/mocks";
+
+import { useDraftCardOperations } from "./use-draft-card-operations";
+
+const card = createMockCard({ id: 1, database_id: 1 });
+const dataset = createMockDataset();
+
+function draftQueryArgs() {
+ return {
+ ...card.dataset_query,
+ database: card.database_id ?? null,
+ parameters: [],
+ };
+}
+
+describe("useDraftCardOperations", () => {
+ it("seeds the adhoc dataset cache synchronously when forking a draft for viz settings (metabase#81349)", () => {
+ const { result, store } = renderHookWithProviders(
+ () =>
+ useDraftCardOperations(undefined, card, card.id, null, null, dataset),
+ {},
+ );
+
+ act(() => {
+ result.current.ensureDraftCard(
+ { visualization_settings: { "graph.show_values": true } },
+ true,
+ );
+
+ // Assert before act() drains microtasks — upsertQueryData would
+ // still be pending here, which remounts QuestionChartSettings.
+ const cached = datasetApi.endpoints.getAdhocQuery.select(
+ draftQueryArgs(),
+ )(store.getState());
+ expect(cached.status).toBe("fulfilled");
+ expect(cached.data).toEqual(dataset);
+ });
+ });
+});