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

Sorting lists #228

Open
edwardhorsford opened this issue Mar 5, 2021 · 1 comment
Open

Sorting lists #228

edwardhorsford opened this issue Mar 5, 2021 · 1 comment
Labels
component Goes in the 'Components' section of the Design System

Comments

@edwardhorsford
Copy link

I thought I'd share what we've done for sorting a list in case it's useful to anyone else. It's very similar (and the markup is slightly borrowed from) the HMRC Welsh language toggle.

Video:
sorting-a-list

Some implementation details:

  • Sorting is just a link that ultimately sets a param in the query string
  • The page uses the query string to work out sorting
  • Make sure to have a default sort order if no query string
  • The links make sure to include any existing query strings (this page has filtering too)
  • We've got some hidden markup to hopefully make this communicate well for screen reader users
  • We're not using aria="current" on the selected item because after a discussion with Leonie Watson on Twitter we were advised that the item not being a link would be sufficient.

For now we've gone with a nav but this might be too verbose. We have an external accessibility audit booked shortly so will report back if it gets flagged.

We chose this over a select for a few reasons:

  • We've only got two options
  • Easier to implement
  • With a select you'd need js to auto-submit or else a submit button

You can find our code for this component here.

@CharlotteDowns
Copy link

This seems to be a specific execution related to the pattern #133 Filter a list

@CharlotteDowns CharlotteDowns added the component Goes in the 'Components' section of the Design System label Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component Goes in the 'Components' section of the Design System
Development

No branches or pull requests

2 participants