Skip to content

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

GDGT-2648 Action menu is too wide when editing a dashboard (#77795)

Kamil Mielnikce8a99bf0856
diff --git a/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js
index d4fa00c82ba..966095fc2c5 100644
--- a/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js
@@ -1665,3 +1665,37 @@ describe("issue 63416", () => {
});
});
});
+
+describe("issue 76056", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ H.setActionsEnabledForDB(SAMPLE_DB_ID);
+
+ H.createDashboard().then(({ body: dashboard }) => {
+ H.visitDashboard(dashboard.id);
+ });
+ });
+
+ it("the dashcard actions panel should not have redundant horizontal space (metabase#76056)", () => {
+ H.editDashboard();
+ cy.button("Add action").click();
+ cy.button("Close").click();
+
+ H.showDashboardCardActions();
+
+ cy.findByTestId("dashboardcard-actions-panel")
+ .should("be.visible")
+ .then(($panel) => {
+ const panelRect = $panel[0].getBoundingClientRect();
+ const buttonRects = Array.from($panel[0].querySelectorAll("a")).map(
+ (button) => button.getBoundingClientRect(),
+ );
+ const maxRight = Math.max(...buttonRects.map((rect) => rect.right));
+ const minLeft = Math.min(...buttonRects.map((rect) => rect.left));
+ const contentWidth = maxRight - minLeft;
+
+ expect(panelRect.width).to.be.closeTo(contentWidth, 10);
+ });
+ });
+});
diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.module.css b/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.module.css
index 49d07b3b23f..53fe218eb8a 100644
--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.module.css
+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.module.css
@@ -7,6 +7,13 @@
}
.DashCardActionsPanelContainer {
+ position: absolute;
+ top: 0;
+ /**
+ * Defined here in CSS rather than via style props, so that the onLeftEdge
+ * container query below can have higher specificity
+ */
+ right: 20px;
min-width: fit-content;
padding: 0.125em 0.25em;
background: var(--mb-color-bg-dashboard-card);
diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.tsx
index dc1cab23fa1..0775fddb984 100644
--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.tsx
+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardActionsPanel/DashCardActionsPanel.tsx
@@ -335,9 +335,6 @@ function DashCardActionsPanelInner({
},
className,
)}
- pos="absolute"
- top={0}
- right="20px"
data-testid="dashboardcard-actions-panel"
data-dontdrag // allows to interact with the actions panel while in the edit mode
onMouseDown={onMouseDown}