overture-stack / arranger

Data portal API and component generation
https://www.overture.bio/documentation/arranger/
GNU Affero General Public License v3.0
29 stars 24 forks source link

Handle sorting for "list" values #844

Open justincorrigible opened 1 year ago

justincorrigible commented 1 year ago

When you click on any column header to sort the rows, depending on which column you select, the first time you click that column you’ll get a mixed result of ascending or descending as the outcome. Turns out this is caused by some shortsighted/opinionated logic within react-table (as seen here https://github.com/TanStack/table/blob/main/packages/table-core/src/features/Sorting.ts#L166), where unless you specify all/any columns should be be sorted first in a specific manner, it choses a default based on whether the value is a plain string or not.

This of course doesn’t work in our usual data models, where though some values show as a string, they come as arrays of strings instead (because we support lists of values), generating the inconsistent behaviour.

I’m adding a default “all columns sort as ascending first” in Arranger (V3 beta 34), but lists require better handling, so I’m creating a ticket to address one later in detail.