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(sdk): Avoid portal root taking space under flex parents (#65088)
Mahatthana (Kelvin) Nomsawadi94e1c1e3870c
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.style.css b/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.style.cssnew file mode 100644index 00000000000..fe2f5da64dc--- /dev/null+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.style.css@@ -0,0 +1,14 @@+.publicComponentWrapper {+ /* Try to reset as much as possible to avoid css leaking from host app to our components */+ all: initial;+ text-decoration: none;+ font-style: normal;+ width: 100%;+ height: 100%;+ font-weight: 400;+ color: var(--mb-color-text-dark);+ font-family: var(--mb-default-font-family);+ -webkit-font-smoothing: antialiased;+ -moz-osx-font-smoothing: grayscale;+ transition: var(--transition-theme-change);+}diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.tsxindex 16b0f0b8707..3ae3cd15458 100644--- a/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.tsx+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/private/PublicComponentStylesWrapper.tsx@@ -1,36 +1,20 @@import { css } from "@emotion/react";import styled from "@emotion/styled";+import cx from "classnames";import type React from "react";import { forwardRef } from "react";import { saveDomImageStyles } from "metabase/visualizations/lib/image-exports";+import S from "./PublicComponentStylesWrapper.style.css";+/*** Injects CSS variables and styles to the SDK components underneath them.* This is to ensure that the SDK components are styled correctly,* even when rendered under a React portal.*/const PublicComponentStylesWrapperInner = styled.div`- // Try to reset as much as possible to avoid css leaking from host app to our components- all: initial;- text-decoration: none;-- font-style: normal;-- width: 100%;- height: 100%;-font-size: ${({ theme }) => theme.other.fontSize};-- font-weight: 400;- color: var(--mb-color-text-dark);- font-family: var(--mb-default-font-family);-- -webkit-font-smoothing: antialiased;- -moz-osx-font-smoothing: grayscale;-- transition: var(--transition-theme-change);-${saveDomImageStyles}`;@@ -44,7 +28,7 @@ export const PublicComponentStylesWrapper = forwardRef<ref={ref}dir="ltr"// eslint-disable-next-line react/prop-types -- className is in div props :shrugs:- className={`mb-wrapper ${props.className}`}+ className={cx("mb-wrapper", S.publicComponentWrapper, props.className)}// Mantine's cssVariablesSelector expects data-mantine-color-scheme to be set on the target elementdata-mantine-color-scheme="light"/>diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.style.css b/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.style.cssnew file mode 100644index 00000000000..794bb7f0b5f--- /dev/null+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.style.css@@ -0,0 +1,4 @@+.portalWrapper {+ /* Avoid taking space inside a container e.g. flex */+ display: contents;+}diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.tsxindex 60d7faa0ea8..465a7a44198 100644--- a/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.tsx+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkPortalContainer.tsx@@ -3,6 +3,7 @@ import { EMBEDDING_SDK_PORTAL_ROOT_ELEMENT_ID } from "metabase/embedding-sdk/conimport { Box } from "metabase/ui";import { PublicComponentStylesWrapper } from "./PublicComponentStylesWrapper";+import S from "./SdkPortalContainer.style.css";/*** This is the portal container used by popovers modals etc, it is wrapped with PublicComponentStylesWrapper@@ -10,7 +11,7 @@ import { PublicComponentStylesWrapper } from "./PublicComponentStylesWrapper";* Mantine components needs to have the defaultProps set to use `EMBEDDING_SDK_PORTAL_ROOT_ELEMENT_ID` as target for the portal*/export const PortalContainer = () => (- <PublicComponentStylesWrapper>+ <PublicComponentStylesWrapper className={S.portalWrapper}><Boxid={EMBEDDING_SDK_PORTAL_ROOT_ELEMENT_ID}className={ZIndex.Overlay}