Skip to content

Commit d96b627

Browse files
committed
Fixes #27292 - workaround for c3 destroy issue (#435)
* Fixes #27292 - workaround for c3 destroy issue There is a known issue in react-c3js that can lead to the charts to disappear due to some race condition during component unmounting/destroy phase bcbcarl/react-c3js#22. Delaying the actual destroy a bit seems to help with workarounding the issue. * Refs #27292 - Add note about no need for explicit bind
1 parent aa61ee4 commit d96b627

File tree

1 file changed

+8
-1
lines changed
  • webpack/ForemanTasks/Components/Chart

1 file changed

+8
-1
lines changed

webpack/ForemanTasks/Components/Chart/Chart.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ class C3Chart extends React.Component {
3838

3939
destroyChart() {
4040
try {
41-
this.chart = this.chart.destroy();
41+
// A workaround for a case, where the chart might be still in transition
42+
// phase while unmounting/destroying - destroying right away leads
43+
// to issue described in https://github.com/bcbcarl/react-c3js/issues/22.
44+
// Delaying the destroy a bit seems to resolve the issue.
45+
// The chart API methods are already bind explicitly, therefore we don't need
46+
// any special handling when passing the function.
47+
setTimeout(this.chart.destroy, 1000);
48+
this.chart = null;
4249
} catch (err) {
4350
throw new Error('Internal C3 error', err);
4451
}

0 commit comments

Comments
 (0)