Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated withHeadings to respect config definition #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MotchQF
Copy link

@MotchQF MotchQF commented Mar 20, 2023

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.

@alomoa
Copy link

alomoa commented Mar 22, 2023

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.

Copy link

@alomoa alomoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants