Updated withHeadings to respect config definition#126
Updated withHeadings to respect config definition#126MotchQF wants to merge 1 commit intoeditor-js:masterfrom
Conversation
|
The bug is due to the getConfig method in plugin.js. It first checks if data exists and if it does to return the withHeadings value from that. The thing is, data object will always exist even when creating a new table, It'll just be empty. So the method will never return from config (where we set our withHeadings). A possible solution could be to have another nested if statement to check if data has any properties inside, something like if Object.keys(data).length > 0 and then proceeding to return the value from data. I tested this and it works for me. |
There was a problem hiding this comment.
Tested this on my machine. Headings are still not present.
The line that's responsible for setting heading is in the render method of plugin.js:
this.table.setHeadingsSetting(this.data.withHeadings);
which is set in the constructor by the following:
this.data = { withHeadings: this.getConfig('withHeadings', false, data), content: data && data.content ? data.content : [] };
The issue I see with getConfig is that it first checks if data is truthy if(data). Data will always be instantiated so this check will pass, but can also be empty which is not good because the config is never checked.
Solution: within the truthy if statement of the render method in plugin.js, check if data actually has properties by checking the length of its keys.
From:
if(data)
To:
if(data && Object.keys(data) > 0)
Settings withHeadings: true in config wasn't updating the default when new tables were created and I believe its due to being hard coded false.