SolidOS / solid-ui

User Interface widgets and utilities for Solid
https://solidos.github.io/solid-ui/dist/solid-ui.js
MIT License
148 stars 41 forks source link

Handling undefined value in table columns? #418

Open josephguillaume opened 3 years ago

josephguillaume commented 3 years ago

In the issue-pane, it is currently possible for a category to have an undefined value, which then means it doesn't show up in the table view.

This occurs because the filterFunction defined by renderEnumSelector in table.js will never return true for an undefined colValue https://github.com/solid/solid-ui/blob/c2d0c8aed526db4e35640d9f3d543434a2c310ec/src/table.js#L1121-L1123

Possible solutions

It is possible this is simply a bug. searchValue defaults to {}, so !searchValue will always be false, even though a comment may or may not suggest the intended behaviour was to return true: https://github.com/solid/solid-ui/blob/c2d0c8aed526db4e35640d9f3d543434a2c310ec/src/table.js#L1099-L1103

In this case, a solution would be to use:

return Object.keys(searchValue).length == 0 || colValue && searchValue[colValue.uri];

However, given that the default behaviour of table.js is to select all options, and on a desktop there is currently no way of unselecting all options, the UI would also need to change.

Instead of a new UI element or interaction to deselect all options (let's call that Solution 1), another solution would then be to add an option for undefined, which would have the advantage of being able to show only those options missing a category (Solution 2).

And rather than doing that automatically within table.js, another option is to simply not support undefined values (and perhaps to include some validation code, Solution 3). issue-pane would then need to make sure that a default value is always assigned for a category.

Not sure which of solution 1-3 would be preferred.

josephguillaume commented 2 years ago

I'm currently leaning towards solution 2, i.e. adding undefined as a value to the selector.

Solution 3 (not supporting undefined values) would only be viable with server side shape validation, otherwise there's always a risk that incomplete data leads to the data not being shown at all.

Solution 2 also seems like a more intuitive UI change than adding an additional "unselect all" (Solution 1)