Skip to content

Commit

Permalink
fix(D3 plugin): fix click event handler (#436)
Browse files Browse the repository at this point in the history
fix(d3): fix click event handler
  • Loading branch information
kuzmadom authored Feb 29, 2024
1 parent e8cfccc commit a7d0b1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release-v4-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ jobs:
node-version: 18
default-branch: v4-2
npm-dist-tag: untagged
skip-github-release: true
skip-labeling: true
8 changes: 5 additions & 3 deletions src/plugins/d3/renderer/components/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ export const Chart = (props: Props) => {
yScale,
svgContainer: svgRef.current,
});

const clickHandler = data.chart?.events?.click;
React.useEffect(() => {
if (data.chart?.events?.click) {
dispatcher.on('click-chart', data.chart?.events?.click);
if (clickHandler) {
dispatcher.on('click-chart', clickHandler);
}

return () => {
dispatcher.on('click-chart', null);
};
}, [dispatcher]);
}, [dispatcher, clickHandler]);

const boundsOffsetTop = chart.margin.top;
const boundsOffsetLeft = chart.margin.left + getWidthOccupiedByYAxis({preparedAxis: yAxis});
Expand Down

0 comments on commit a7d0b1d

Please sign in to comment.