Skip to content

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

Fix #66585: Updates static embeds to omit color-scheme settings to preserve legacy transparent iframe behavior (#66662)

Brad Anderson4794cc30819c
diff --git a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/PreviewPane/PreviewPane.module.css b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/PreviewPane/PreviewPane.module.css
index e6560f21316..9e0ece0a8d2 100644
--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/PreviewPane/PreviewPane.module.css
+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/PreviewPane/PreviewPane.module.css
@@ -8,5 +8,12 @@
width: 100%;
min-height: 17.5rem;
background-image: var(--background-url);
- color-scheme: normal; /* Prevents browsers from adding their own "canvas color" to the preview window */
+
+ /*
+ Preserves legacy transparent iframe behavior (metabase#66585).
+ For iframes to be transparent, the `color-scheme` of the iframe and embedded document must match.
+ https://www.w3.org/TR/css-color-adjust-1/#color-scheme-effect
+ Prior to v57, the app's color-scheme was treated as `light` since there were no native "color-scheme" settings defined.
+ */
+ color-scheme: light;
}
diff --git a/frontend/src/metabase/styled-components/containers/GlobalStyles/GlobalStyles.tsx b/frontend/src/metabase/styled-components/containers/GlobalStyles/GlobalStyles.tsx
index e22f1716fcd..f4ec897b80d 100644
--- a/frontend/src/metabase/styled-components/containers/GlobalStyles/GlobalStyles.tsx
+++ b/frontend/src/metabase/styled-components/containers/GlobalStyles/GlobalStyles.tsx
@@ -4,6 +4,10 @@ import { useMemo } from "react";
import { baseStyle, rootStyle } from "metabase/css/core/base.styled";
import { defaultFontFiles } from "metabase/css/core/fonts.styled";
+import {
+ isPublicEmbedding,
+ isStaticEmbedding,
+} from "metabase/embedding/config";
import { getSitePath } from "metabase/lib/dom";
import { useSelector } from "metabase/lib/redux";
import { getMetabaseCssVariables } from "metabase/styled-components/theme/css-variables";
@@ -45,7 +49,9 @@ export const GlobalStyles = (): JSX.Element => {
${saveDomImageStyles}
body {
font-size: 0.875em;
- color-scheme: ${colorScheme};
+ ${isStaticEmbedding() || isPublicEmbedding()
+ ? ""
+ : `color-scheme: ${colorScheme};`}
${rootStyle}
}
diff --git a/src/metabase/server/routes/index.clj b/src/metabase/server/routes/index.clj
index 4a108e244d7..12f37c75fe5 100644
--- a/src/metabase/server/routes/index.clj
+++ b/src/metabase/server/routes/index.clj
@@ -103,7 +103,8 @@
:enableGoogleAuth (boolean google-auth-client-id)
:enableAnonTracking (boolean anon-tracking-enabled)
;; (metabase#65533) color-scheme meta tag breaks EAJS because it has a transparent background.
- :hasColorSchemeMetaTag (not= entrypoint-name "embed-sdk")}))
+ ;; (metabase#66585) Also omit for static/public embedding to preserve legacy behavior for transparent iframes.
+ :hasColorSchemeMetaTag (not (contains? #{"embed-sdk" "embed" "public"} entrypoint-name))}))
(defn- load-entrypoint-template [entrypoint-name embeddable? opts]
(load-template