Griddle
Griddle copied to clipboard
Columns with dots in their property names will be empty
Griddle version
v1.9.0
Expected Behavior
Columns with dots in their ids should show their contents.
Actual Behavior
Columns with dots in their names have no data.
This is the same issue as before, but the code is all different.
https://github.com/GriddleGriddle/Griddle/issues/228
I tracked it down to this line:
https://github.com/griddlegriddle/griddle/blob/master/src/selectors/dataSelectors.js#L265..L265
Since you're splitting the property name by dots, this is going to try to access properties that don't exist.
Steps to reproduce
- Set up a Griddle table with a data column like "foo.bar"
- Look at the table.
Pull request with failing test or storybook story with issue
TODO (trying to figure out how best to do this right now, or whether I should just work around it in my app for now)
Looking at the git blame, it seems like it's intended that you should be able to use dots to access nested values? If so, how should one use columns that have dots in the names? I think for now I'll just work around this in my app by filtering the data before passing it to Griddle.
Nested data support was introduced in https://github.com/GriddleGriddle/Griddle/pull/572.
I wonder if it would make sense to support nestedData={false}
or similar? Or we could update cellValueSelector
to (essentially) get(columnId) || getIn(columnId.split('.'))
.
As you note, the work-around would be to map the data to objects with simple column names.
Ah okay, so it's totally intentional new behavior. Thanks!
A prop would be nice, or changing the behavior to get(columnId) || getIn(columnId.split('.'))
would probably be even better because it seems like it's not necessarily something that you expect, especially if your application is rendering user-submitted data.
So this issue is still open and no fix is it?