frappe/datatable

In function removeStyle() this.stylesheet is null

faburem opened this issue · 1 comments

We are occasionally seeing the following error stack in our app using Frappe datatable:
Screenshot 2020-01-26 at 12 34 17
It seems to be related to the timing when the datatable is rendered on the page because it is not happening every time.
I am wondering if we could add a check here to prevent this.stylesheet to be null and thus preventing the error stack above:

const index = Array.from(this.stylesheet.cssRules)

Turns out this was not related to frappe datatable but to the way the framework we are using (Meteor.js) cleans up after itself (spoiler alert: it's bad). For anybody else trying this combination, here is how to resolve it (assuming that you create a datatable instance in the onRendered Callback and store it's reference in the template instance:

Template.yourTemplate.onDestroyed(() => {
  Template.instance().datatable.destroy()
  Template.instance().datatable = undefined
})