diff --git a/e2e/test/scenarios/sharing/public-dashboard.cy.spec.js b/e2e/test/scenarios/sharing/public-dashboard.cy.spec.js index e3f5269f1278161abe4c5382c163b1861b885fe2..620b3a74e18ab351880e5dd124f4cb0a41dad648 100644 --- a/e2e/test/scenarios/sharing/public-dashboard.cy.spec.js +++ b/e2e/test/scenarios/sharing/public-dashboard.cy.spec.js @@ -2,10 +2,12 @@ import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; import { assertDashboardFixedWidth, assertDashboardFullWidth, + createDashboardWithQuestions, createPublicDashboardLink, dashboardParametersContainer, describeEE, filterWidget, + getDashboardCard, goToTab, openNewPublicLinkDropdown, openSharingMenu, @@ -17,7 +19,7 @@ import { visitPublicDashboard, } from "e2e/support/helpers"; -const { PRODUCTS } = SAMPLE_DATABASE; +const { PRODUCTS, ORDERS_ID } = SAMPLE_DATABASE; const questionDetails = { name: "sql param", @@ -286,6 +288,54 @@ describe("scenarios > public > dashboard", () => { cy.findByText("Registerkarte als PDF exportieren").should("be.visible"); cy.url().should("include", "locale=de"); }); + + it("should respect click behavior", () => { + createDashboardWithQuestions({ + dashboardName: "test click behavior", + questions: [ + { + name: "orders", + query: { + "source-table": ORDERS_ID, + limit: 5, + }, + }, + ], + cards: [ + { + visualization_settings: { + column_settings: { + '["name","TOTAL"]': { + click_behavior: { + type: "link", + linkType: "url", + linkTemplate: "https://metabase.com", + }, + }, + }, + }, + }, + ], + }).then(({ dashboard }) => { + visitPublicDashboard(dashboard.id); + }); + + // This is a hacky way to intercept the link click we create an a element + // with href on fly and remove it afterwards in lib/dom.js + cy.window().then(win => { + cy.spy(win.document.body, "appendChild").as("appendChild"); + }); + + getDashboardCard().findByText("39.72").click(); + + cy.get("@appendChild").then(appendChild => { + // last call is a link + const element = appendChild.lastCall.args[0]; + + expect(element.tagName).to.eq("A"); + expect(element.href).to.eq("https://metabase.com/"); + }); + }); }); describeEE("scenarios [EE] > public > dashboard", () => { diff --git a/frontend/src/metabase/dashboard/components/DashboardGrid.tsx b/frontend/src/metabase/dashboard/components/DashboardGrid.tsx index 5f65b0d112c5ebe3cda3625bf4436f42f7f7bb3e..6e2acaca12c3d9fa58c8ae8ade0056b9eda7dddc 100644 --- a/frontend/src/metabase/dashboard/components/DashboardGrid.tsx +++ b/frontend/src/metabase/dashboard/components/DashboardGrid.tsx @@ -139,7 +139,7 @@ type OwnProps = { mode?: QueryClickActionsMode | Mode; // public dashboard passes it explicitly width?: number; - // public dashboard passes it as noop + // public or embedded dashboard passes it as noop navigateToNewCardFromDashboard?: ( opts: NavigateToNewCardFromDashboardOpts, ) => void; diff --git a/frontend/src/metabase/visualizations/components/Visualization/Visualization.jsx b/frontend/src/metabase/visualizations/components/Visualization/Visualization.jsx index cc49072d93b18fd7f7b1175a4c38374384973749..d0868e0cb0dfedd47a4abb032d8c879e3b2c437f 100644 --- a/frontend/src/metabase/visualizations/components/Visualization/Visualization.jsx +++ b/frontend/src/metabase/visualizations/components/Visualization/Visualization.jsx @@ -245,10 +245,6 @@ class Visualization extends PureComponent { } visualizationIsClickable = clicked => { - const { onChangeCardAndRun } = this.props; - if (!onChangeCardAndRun) { - return false; - } try { return this.getClickActions(clicked).length > 0; } catch (e) {