moj-frontend
moj-frontend copied to clipboard
Sortable table is persistent
Summary
Make the sorted data of a sortable table (https://design-patterns.service.justice.gov.uk/components/sortable-table/) stay sorted for the duration of a user's session.
Motivation
Users interacting with a sorted table refer back to it as part of task completion, and expectation is that it remains in the state they left it in.
Describe alternatives you've considered
Users can re-sort, but this is not a great user experience. It would be much better for work done not to be 'undone' in this instance.
Additional context
The persistent pattern is particularly necessary where the sortable table contains links, as users get 'lost' when returning to the screen.
We could add a persistent option to sortable (so that it's not default behaviour, for backwards compatibility) that:
- Stores the column and sort order whenever the table is sorted
- Uses the stored column and order when the page is loaded
We'd need the user to pass in an ID to store it under so that if there are multiple Sortables in an application they don't all persist with the same setting (but by sharing an ID, you could link two identical-in-practice tables).