Skip to content

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

Fix dashboard question breadcrumb layout (#76345)

Anderson0d432c97f13f
diff --git a/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx b/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx
index 9da5603586a..0756c59561a 100644
--- a/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx
+++ b/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx
@@ -82,14 +82,12 @@ export const CollectionBreadcrumbs = ({
);
return (
- <>
- <Flex align="center" miw="0">
- {content}
- <CollectionBadge
- collectionId={collection.id}
- onClick={onClick ? () => onClick(collection) : undefined}
- />
- </Flex>
+ <Flex align="center" miw="0">
+ {content}
+ <CollectionBadge
+ collectionId={collection.id}
+ onClick={onClick ? () => onClick(collection) : undefined}
+ />
{dashboard && (
<>
{separator}
@@ -99,7 +97,7 @@ export const CollectionBreadcrumbs = ({
</Breadcrumb>
</>
)}
- </>
+ </Flex>
);
};
diff --git a/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.unit.spec.tsx b/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.unit.spec.tsx
new file mode 100644
index 00000000000..8b89939c854
--- /dev/null
+++ b/frontend/src/metabase/nav/components/CollectionBreadcrumbs/CollectionBreadcrumbs.unit.spec.tsx
@@ -0,0 +1,59 @@
+import { Route } from "react-router";
+
+import { setupCollectionByIdEndpoint } from "__support__/server-mocks";
+import { renderWithProviders, screen } from "__support__/ui";
+import {
+ createMockCollection,
+ createMockDashboard,
+} from "metabase-types/api/mocks";
+
+import { CollectionBreadcrumbs } from "./CollectionBreadcrumbs";
+
+const COLLECTION = createMockCollection({
+ id: 3,
+ name: "Foo Collection",
+});
+
+const DASHBOARD = createMockDashboard({
+ id: 4,
+ name: "Bar Dashboard",
+ collection_id: 3,
+});
+
+function setup() {
+ setupCollectionByIdEndpoint({ collections: [COLLECTION] });
+
+ return renderWithProviders(
+ <Route
+ path="*"
+ component={() => (
+ <CollectionBreadcrumbs
+ baseCollectionId={null}
+ collection={COLLECTION}
+ dashboard={DASHBOARD}
+ />
+ )}
+ />,
+ { withRouter: true },
+ );
+}
+
+describe("CollectionBreadcrumbs", () => {
+ it("renders dashboard breadcrumbs inside the same wrapper as collection breadcrumbs (#76202)", async () => {
+ const { container } = setup();
+
+ const collectionLink = (await screen.findByText("Foo Collection")).closest(
+ "a",
+ );
+ const dashboardLink = screen.getByText("Bar Dashboard").closest("a");
+
+ expect(collectionLink).not.toBeNull();
+ expect(dashboardLink).not.toBeNull();
+ expect(collectionLink?.parentElement).toBe(dashboardLink?.parentElement);
+ expect(
+ Array.from(container.children).filter(
+ (child) => child.tagName.toLowerCase() !== "style",
+ ),
+ ).toHaveLength(1);
+ });
+});