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

Convert table cell header into undefined if it's been provided to EuiBasicTable as a non-string node. #1312

Merged
merged 6 commits into from
Nov 16, 2018

Conversation

cjcenizal
Copy link
Contributor

This fixes a prop-type warning and poor UI when you provide a non-string node. This PR also changes the name prop-type of action columns to node, leftover from #1234.

Before

image

After

image

…to EuiBasicTable as a non-string node.

- Change name prop-type of action columns to node.
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on to fix it. It think this is an ok fix for now, but may be odd for consumers who don't see their column headers in responsive view. I have a note to myself to fix some of the responsive table stuff so I'll just add handling of non-string headers to that.

I noticed that I always display a space for the mobile header even if the data attribute doesn't exist, which is why there's so much spacing in your screenshot. Can you change this line:

to &[data-header]::before { ?

// Name can also be an array or an element, so we need to convert it into a string. We can't
// stringify the value, because this value is rendered directly in the mobile layout. So the
// best thing we can do is render nothing.
const header = typeof name === 'string' ? name : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's best to let the EuiTableRowCell handle this since it's the one that places the prop in a string-only data attribute. It will also be there to catch for anyone who builds their own custom tables.

@cjcenizal
Copy link
Contributor Author

Thanks @cchaos I made the change to hide the header:

image

Per our convo I'll defer changing the prop type until we make the change to render the header using React instead of CSS.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Thanks for adding in the CSS fix!

@cjcenizal cjcenizal merged commit 55dc7f7 into elastic:master Nov 16, 2018
@cjcenizal cjcenizal deleted the table-header-node-prop-type branch November 16, 2018 17:15
@cjcenizal cjcenizal changed the title Convert table cell header into an empty string if it's been provided to EuiBasicTable as a non-string node. Convert table cell header into undefined if it's been provided to EuiBasicTable as a non-string node. Nov 16, 2018
@snide snide mentioned this pull request Nov 30, 2018
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants