moj-frontend icon indicating copy to clipboard operation
moj-frontend copied to clipboard

Sortable table is persistent

Open liammcmurray opened this issue 4 years ago • 1 comments

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.

liammcmurray avatar Sep 20 '21 12:09 liammcmurray

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).

gregtyler avatar Sep 20 '21 13:09 gregtyler