Skip to content

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

Keep long chart tooltip values readable within the viewport (#77947)

Andersoncda8f7d30155
diff --git a/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.ts b/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.ts
index 0bfd0fb0385..5357254b68f 100644
--- a/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.ts
@@ -506,6 +506,68 @@ union all select 'Medium length category', 30 as count`;
});
});
+describe("issue 68337", () => {
+ const longTooltipValue = "a".repeat(10000);
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+ });
+
+ it("should wrap long values without expanding the tooltip beyond the viewport (metabase#68337)", () => {
+ H.visitQuestionAdhoc({
+ display: "line",
+ dataset_query: {
+ type: "native",
+ native: {
+ query: `select 1 as x, 10 as metric_value, '${longTooltipValue}' as details
+union all select 2, 20, 'short value'`,
+ },
+ database: SAMPLE_DB_ID,
+ },
+ visualization_settings: {
+ "graph.dimensions": ["X"],
+ "graph.metrics": ["METRIC_VALUE"],
+ "graph.tooltip_columns": [JSON.stringify(["name", "DETAILS"])],
+ },
+ });
+
+ H.cartesianChartCircle()
+ .should("have.length", 2)
+ .first()
+ .trigger("mousemove");
+
+ cy.window().then((appWindow) => {
+ H.echartsTooltip().then(($tooltip) => {
+ const tooltipRoot = $tooltip[0].parentElement;
+ expect(tooltipRoot).not.to.be.null;
+ if (tooltipRoot == null) {
+ return;
+ }
+
+ const tooltipBounds = tooltipRoot.getBoundingClientRect();
+
+ expect(tooltipBounds.left).to.be.at.least(0);
+ expect(tooltipBounds.right).to.be.at.most(appWindow.innerWidth);
+ expect(tooltipBounds.height).to.be.at.most(appWindow.innerHeight * 0.8);
+ expect(tooltipRoot.scrollHeight).to.be.greaterThan(
+ tooltipRoot.clientHeight,
+ );
+ });
+ });
+
+ H.echartsTooltip()
+ .findByText(longTooltipValue)
+ .should(($value) => {
+ const value = $value[0];
+ const fontSize = Number.parseFloat(getComputedStyle(value).fontSize);
+
+ expect(value.scrollWidth).to.be.at.most(value.clientWidth);
+ expect(value.clientHeight).to.be.greaterThan(fontSize * 2);
+ });
+ });
+});
+
describe("issue 55853", () => {
const questionDetails = {
name: "55853",
diff --git a/frontend/src/metabase/visualizations/components/ChartTooltip/EChartsTooltip/EChartsTooltip.module.css b/frontend/src/metabase/visualizations/components/ChartTooltip/EChartsTooltip/EChartsTooltip.module.css
index 67194c8297b..62b7628d967 100644
--- a/frontend/src/metabase/visualizations/components/ChartTooltip/EChartsTooltip/EChartsTooltip.module.css
+++ b/frontend/src/metabase/visualizations/components/ChartTooltip/EChartsTooltip/EChartsTooltip.module.css
@@ -5,6 +5,8 @@
border: none !important;
padding: 0 !important;
color: var(--mb-color-tooltip-text) !important;
+ max-height: 80vh;
+ overflow-y: auto !important;
}
.Table {
@@ -14,8 +16,6 @@
}
.TableWrapper {
- max-height: 80vh;
- overflow-y: auto;
position: relative;
margin: 0.25rem 0 0.875rem;
}
@@ -88,6 +88,13 @@
width: 1px;
}
+.MainValueCell {
+ width: auto;
+ max-width: 360px;
+ white-space: normal;
+ overflow-wrap: anywhere;
+}
+
.SecondaryValueCell {
font-weight: 600;
color: var(--mb-color-tooltip-text-secondary);