Skip to content
Snippets Groups Projects
Unverified Commit 0fb138af authored by Aleksandr Lesnenko's avatar Aleksandr Lesnenko Committed by GitHub
Browse files

Fix RowChart shrinks on hover (#43634)

* fix memoization

* extend the basic row chart e2e spec
parent 4ec415a0
No related branches found
No related tags found
No related merge requests found
......@@ -79,5 +79,18 @@ describe("scenarios > visualizations > rows", () => {
});
cy.findByText("COLUMN_TWO");
});
// Verify hovering bars does not change their size (metabase#43631)
cy.findAllByRole("graphics-symbol").eq(0).as("firstBar");
cy.get("@firstBar")
.invoke("width")
.then(prevWidth => {
cy.get("@firstBar")
.realHover()
.invoke("width")
.then(newWidth => {
expect(prevWidth).eq(newWidth);
});
});
});
});
......@@ -85,7 +85,7 @@ export const Default = Template.bind({});
Default.args = DEFAULT_ROW_CHART_ARGS;
const ThemedRowChart = () => {
const theme = useRowChartTheme({ fontFamily: "Lato" });
const theme = useRowChartTheme("Lato");
return (
<Box h={600} bg="white" p="8px">
......
......@@ -135,7 +135,7 @@ const RowChartVisualization = ({
);
const goal = useMemo(() => getChartGoal(settings), [settings]);
const stackOffset = getStackOffset(settings);
const theme = useRowChartTheme({ fontFamily });
const theme = useRowChartTheme(fontFamily);
const chartWarnings = useMemo(
() => getChartWarnings(chartColumns, data.rows),
......
......@@ -5,17 +5,12 @@ import { useMantineTheme } from "metabase/ui";
import type { RowChartTheme } from "metabase/visualizations/shared/components/RowChart/types";
import { getVisualizationTheme } from "metabase/visualizations/shared/utils/theme";
interface RowChartThemeOptions {
fontFamily?: string;
}
export const useRowChartTheme = (
options: RowChartThemeOptions,
fontFamily: string = "Lato",
): RowChartTheme => {
const theme = useMantineTheme();
return useMemo(() => {
const { fontFamily = "Lato" } = options;
const { cartesian } = getVisualizationTheme(theme.other);
return {
......@@ -53,5 +48,5 @@ export const useRowChartTheme = (
color: color("border"),
},
};
}, [options, theme]);
}, [theme, fontFamily]);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment