The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix pivot tables in static embedding having white cell backgrounds in dark mode (#61939)
Phoomparin Manoa1206f3886ea
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.jsindex 55eb1315f9c..8b5cd616e9c 100644--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js@@ -1059,6 +1059,95 @@ describe("scenarios > embedding > dashboard appearance", () => {H.main().should("have.css", "font-family", "Roboto, sans-serif");});++ it("should use transparent pivot table cells in static embedding's dark mode (metabase#61741)", () => {+ const testQuery = {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ PEOPLE.SOURCE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ],+ [+ "field",+ PRODUCTS.CATEGORY,+ { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },+ ],+ ],+ },+ database: 1,+ };++ const pivotQuestionDetails = {+ name: "Pivot Table Test",+ query: testQuery.query,+ display: "pivot",+ };++ const pivotDashboardDetails = {+ name: "Pivot Dashboard Test",+ enable_embedding: true,+ embedding_params: {},+ };++ H.createQuestionAndDashboard({+ questionDetails: pivotQuestionDetails,+ dashboardDetails: pivotDashboardDetails,+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);++ H.openStaticEmbeddingModal({+ activeTab: "parameters",+ previewMode: "preview",+ acceptTerms: false,+ });++ H.modal().within(() => {+ cy.findByRole("tab", { name: "Look and Feel" }).click();++ cy.log("wait until we are at the night theme");+ cy.findByLabelText("Dark").click({ force: true });+ H.getIframeBody()+ .findByTestId("embed-frame")+ .invoke("attr", "data-embed-theme")+ .should((embedTheme) => {+ expect(embedTheme).to.eq("night");+ });++ H.getIframeBody().findByTestId("pivot-table").should("be.visible");++ H.getIframeBody().within(() => {+ cy.findAllByTestId("pivot-table-cell").should(+ "have.length.greaterThan",+ 0,+ );++ cy.log("dashcard should have dark background");+ cy.findByTestId("dashcard").should(+ "have.css",+ "background-color",+ "rgb(46, 53, 59)",+ );++ cy.log("pivot table cell background should be transparent");+ cy.findAllByRole("grid")+ .first()+ .findAllByTestId("pivot-table-cell")+ .first()+ .should("have.css", "background-color", "rgba(46, 53, 59, 0.1)");++ cy.log("pivot table cell color should be white");+ cy.findByText("Row totals")+ .should("be.visible")+ .should("have.css", "color", "rgb(255, 255, 255)");+ });+ });+ });+ });});function openFilterOptions(name) {diff --git a/frontend/src/metabase/dashboard/context/context.redux.ts b/frontend/src/metabase/dashboard/context/context.redux.tsindex 611d0e8e895..cbfe4215171 100644--- a/frontend/src/metabase/dashboard/context/context.redux.ts+++ b/frontend/src/metabase/dashboard/context/context.redux.ts@@ -55,6 +55,7 @@ import {undoDeleteTab,} from "metabase/dashboard/actions/tabs";import { connect } from "metabase/lib/redux";+import { getIsEmbeddingIframe } from "metabase/selectors/embed";import {canManageSubscriptions,getUserIsAdmin,@@ -117,6 +118,7 @@ export const mapStateToProps = (state: State) => ({isNavigatingBackToDashboard: getIsNavigatingBackToDashboard(state),isLoading: getIsLoading(state),isLoadingWithoutCards: getIsLoadingWithoutCards(state),+ isEmbeddingIframe: getIsEmbeddingIframe(state),});export const mapDispatchToProps = {diff --git a/frontend/src/metabase/dashboard/context/context.tsx b/frontend/src/metabase/dashboard/context/context.tsxindex 28ad8340d74..355d2cb258b 100644--- a/frontend/src/metabase/dashboard/context/context.tsx+++ b/frontend/src/metabase/dashboard/context/context.tsx@@ -147,6 +147,7 @@ const DashboardContextProviderInner = forwardRef(isLoading,isLoadingWithoutCards,parameters,+ isEmbeddingIframe,// redux actionsaddCardToDashboard,@@ -194,7 +195,9 @@ const DashboardContextProviderInner = forwardRef(setTheme,} = useDashboardTheme(initTheme);- const shouldRenderAsNightMode = Boolean(isNightMode && isFullscreen);+ const shouldRenderAsNightMode = Boolean(+ isNightMode && (isFullscreen || isEmbeddingIframe),+ );const handleError = useCallback((error: unknown) => {@@ -402,6 +405,7 @@ const DashboardContextProviderInner = forwardRef(isNavigatingBackToDashboard,parameters,parameterValues,+ isEmbeddingIframe,// redux actionsaddCardToDashboard,