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

Table: Add sortable columns #807

Open
brentswisher opened this issue Aug 30, 2024 · 0 comments
Open

Table: Add sortable columns #807

brentswisher opened this issue Aug 30, 2024 · 0 comments

Comments

@brentswisher
Copy link
Contributor

brentswisher commented Aug 30, 2024

The problem
When viewing a large data set in a pharos table, it would be nice to be able to click the headings and have the table resort it based on that column.

The solution
Add a sortable property which will enable the UI for sorting a table. Clicking a sort element will emit a custom event pharos-table-sort which the consuming application is in charge of listening for and sorting the data that is passed into the table as needed.

The custom event will also need to provide the current pagination values so that the parent application can handle resetting the page or not based on the needs of the application.

Individual columns could have a new optional key like disableSort to disable sorting on that specific column.

Alternatives considered
Implementing some sort of sorting logic internal to the component. Because the table is mostly a display component this seems difficult to do well, by utilizing a callback the consumer can be responsible for determining the sort type and implementing it. We could add some examples of various methods to storybook to help get people started.

Add an optional onSort property to the table which accepts a callback that is fired when a column is clicked. The UI for sorting could be shown only when this property is set, meaning the default experience would remain the same. The callback could be passed the column that was clicked, and the sort order. The callback itself would be wholly repsponsible for sorting the data before it is passed into the table,

Additional information
Potential Design, although we would want to work with the design team to finalize it:
Screenshot 2024-08-30 at 1 27 30 PM

@daneah daneah changed the title Add sortable table columns Table: Add sortable columns Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant