Skip to content

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

Add overflow-wrap to tooltip content globally (#74625)

Nick Fitzpatrickfd504cf5cac1
diff --git a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts b/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts
index 12cb73c458d..f74e20f12b1 100644
--- a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts
+++ b/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts
@@ -6,7 +6,7 @@ import {
ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
-const { PRODUCTS_ID } = SAMPLE_DATABASE;
+const { PRODUCTS_ID, ORDERS_ID } = SAMPLE_DATABASE;
const verifiedFilterToggleButton = () =>
cy
@@ -409,3 +409,34 @@ describe("issue 37907", () => {
H.popover().should("include.text", "Discount amount.");
});
});
+
+describe("issue 74433", () => {
+ const LONG_TABLE_NAME =
+ "thisisaverylongtablenamewithoutspacesthatshouldoverflowthetooltipboxbecausetherearenospacesforbreakingxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ cy.request("PUT", `/api/table/${ORDERS_ID}`, {
+ display_name: LONG_TABLE_NAME,
+ });
+ });
+
+ it("table-name tooltip in Browse Databases should not overflow when the name has no spaces (metabase#74433)", () => {
+ cy.visit(`/browse/databases/${SAMPLE_DB_ID}`);
+
+ // Browse cards actually have a <Title> as the child of the <Ellipsified> component,
+ // so we need to target the parent for the hover
+ cy.findByRole("heading", { name: LONG_TABLE_NAME }).parent().realHover();
+
+ H.tooltip()
+ .should("be.visible")
+ .and(($tooltip) => {
+ const tooltip = $tooltip[0];
+ expect(
+ tooltip.scrollWidth,
+ "tooltip content fits within its box",
+ ).to.be.lte(tooltip.clientWidth);
+ });
+ });
+});
diff --git a/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.module.css b/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.module.css
index 2c9f95147dc..4845cd042dc 100644
--- a/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.module.css
+++ b/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.module.css
@@ -5,6 +5,8 @@
padding: 0.6rem 0.75rem;
white-space: unset;
max-width: 320px;
+ /* Break long unbreakable strings so the tooltip can't overflow its max-width (metabase#74433). */
+ overflow-wrap: anywhere;
}
.arrow {