mendixlabs / ChartJS

A Mendix widget that wraps the ChartJS library.
https://appstore.home.mendix.com/link/app/1712/Mendix/ChartJS-Widget
Apache License 2.0
4 stars 28 forks source link

MX 7.4 issue with conditional visibility #103

Closed JelteMX closed 7 years ago

JelteMX commented 7 years ago

Comment from #102 from @recktenwaldfabian


The problem that I encounter is, that the widget is initialized and directly uninitialized again (only happens in 7.4, probably due to refresh+conditional visibility). I don’t have a small test project for this yet.

What happens: in a mx.data callback in PieChart.js:111 html.set(this._numberNode, content !== null ? content.toString() : "");

this._numberNode is undefined (probably because the widget is already _destroyed).

The fix would consist of checking if this._destroyed===true before calling _processData.

Can you suggest on how to proceed with this? I’m already spending too much time looking for platform issues and setting up test projects…

JelteMX commented 7 years ago

Makes sense, I'll see if we can fix that

JelteMX commented 7 years ago

I will also test it in a test-project here

recktenwaldfabian commented 7 years ago

I just added this to Core.js and replace usage of _processData with _processDataChecked

        // assert that widget is not already destroyed before processing data
        _processDataChecked: function() {
          if ( this._destroyed ) {
            logger.debug(this.id + " is already destroyed");
          } else {
            this._processData();
          }
        },
JelteMX commented 7 years ago

Got it, came up with something similar. Can you test this version for me?

recktenwaldfabian commented 7 years ago

I can confirm that this is fixing my issue, but:

this._destroyed is set in _WidgetBase.js

I would think twice before setting that yourself.

JelteMX commented 7 years ago

You're right, let's not do that :-). Thanks! I'll update the code and create a new release