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
Fixes isSticky class not being properly applied to dashboard parameters (#69623)
Sébastien60b86d85a507
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.jsindex e305942d2eb..7334cebc5a2 100644--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js@@ -285,6 +285,47 @@ describe("scenarios > embedding > dashboard parameters", () => {cy.findByTestId("scalar-value").invoke("text").should("eq", "1");});+ it("should not apply IsSticky class to the parameter panel before it actually becomes sticky (metabase#66742)", () => {+ H.visitDashboard("@dashboardId");+ H.editDashboard();++ // Duplicating twice to make a scrollable dashboard+ H.getDashboardCard(0)+ .realHover({ scrollBehavior: "bottom" })+ .findByLabelText("Duplicate")+ .click();++ H.getDashboardCard(0)+ .realHover({ scrollBehavior: "bottom" })+ .findByLabelText("Duplicate")+ .click();++ H.saveDashboard();++ cy.get("@dashboardId").then((dashboardId) => {+ H.openLegacyStaticEmbeddingModal({+ resource: "dashboard",+ resourceId: dashboardId,+ activeTab: "parameters",+ });+ });++ H.setEmbeddingParameter("Name", "Editable");++ H.publishChanges("dashboard");++ H.visitIframe();++ // Scrolling duration is needed to let the time to React to update the className...+ cy.findByTestId("embed-frame").scrollTo(0, 20, {+ duration: 1000,+ });++ cy.findByTestId("dashboard-parameters-widget-container")+ .invoke("attr", "class")+ .should("not.contain", "IsSticky");+ });+it("should (dis)allow setting parameters as required for a published embedding", () => {H.visitDashboard("@dashboardId");diff --git a/frontend/src/metabase/dashboard/hooks/use-is-parameter-panel-sticky.ts b/frontend/src/metabase/dashboard/hooks/use-is-parameter-panel-sticky.tsindex 4df506c82e8..7dccd27ea83 100644--- a/frontend/src/metabase/dashboard/hooks/use-is-parameter-panel-sticky.ts+++ b/frontend/src/metabase/dashboard/hooks/use-is-parameter-panel-sticky.ts@@ -26,10 +26,11 @@ export function useIsParameterPanelSticky({sentinel.style.top = "0";sentinel.style.visibility = "hidden";- // Insert sentinel before the parent of our sticky element- const parent = parameterPanelRef.current.parentElement;- if (parent) {- parent.insertBefore(sentinel, parameterPanelRef.current);+ if (parameterPanelRef.current) {+ parameterPanelRef.current.insertBefore(+ sentinel,+ parameterPanelRef.current.firstChild,+ );}const settings: IntersectionObserverInit = {diff --git a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsxindex d95b0c3569a..2faf669ee34 100644--- a/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx+++ b/frontend/src/metabase/public/components/EmbedFrame/EmbedFrame.tsx@@ -253,7 +253,7 @@ export const EmbedFrame = ({{/* show floating header buttons if there is no title */}{headerButtons && !titled ? headerButtons : null}- <span ref={parameterPanelRef} />+ <span ref={parameterPanelRef} style={{ position: "relative" }} />{hasVisibleParameters && (<FullWidthContainerclassName={cx(EmbedFrameS.ParameterPanel, {