hmrc / design-patterns

Documenting HMRC design patterns
http://hmrc.github.io/assets-frontend/
MIT License
32 stars 4 forks source link

Pagination #172

Open klaudiarybicka opened 2 years ago

klaudiarybicka commented 2 years ago

Proposed accessible pagination component and search results pattern. The pattern was added to the HMRC backlog by the working group after a presentation by Dan Lacey (10/09/21). The majority of the information below is taken from that presentation...

Overview

Many of our services have required a search results pagination component & pattern that is intuitive, recognisable to users and accessible to users of assistive technology.

There are already a variety of pagination patterns and implementations across different GOV and HMRC services. There is little consistency within these patterns, although they all have their merits and drawbacks.

While some of these patterns use some good concepts in terms of visual design and accessibility, there doesn’t seem to be a recognised pattern that fulfils most or all of the requirements in terms of accessibility.

Component requirements based on user needs

Implementation examples

Register of fair rents

https://www.tax.service.gov.uk/check-register-fair-rents/search

Ministry of Justice

https://design-patterns.service.justice.gov.uk/components/pagination/

HMCTS

https://hmcts-design-system.herokuapp.com/components/pagination

Some examples of HMRC services using pagination

Existing patterns

There is a number of patterns available already within different GOV.UK services as well as within the HMRC itself. The work on this proposed HMRC pattern extends the work already undertaken by two teams:

Her Majesty’s Courts & Tribunal Service (HMCTS) Design System

https://hmcts-design-system.herokuapp.com/components/pagination

Ministry of Justice (MoJ) Design System

https://design-patterns.service.justice.gov.uk/components/pagination/

The MoJ / HMCTS pattern

image

Proposed component/pattern

image image

There isn’t much of a visual change to the MoJ & HMCTS pattern, however:

Almost all of the improvements to these patterns is to the underlying HTML code structure.

Code improvements

To enhance accessibility, there has been a number of changes to the HTML and semantic structure of the code.

image

Number of results: provide context using the table caption

The advantage of vertically stacking the pagination and the number of results information is that the latter can be placed into the table’s caption element.

image

Use aria-label to describe the pagination navigation element to screen-reader users

In previous iterations of this component, hidden paragraph text is used with an aria label (aria-labelledby) to describe the component as ‘Search results pagination’.

In the proposed version, the paragraph text is removed and the aria control placed directly on the navigation component, streamlining the code:

image

Pagination: enhancing the HTML for accessibility

In the MoJ / HMCTS pattern, list items are used for each page number and link. For links to pages, list items

  • have been replaced with span tags.

    Screen-readers users do not have to listen to repeated list items and only the pagination number in the link is voiced for each page link.

    image

    Current page described by aria-label

    Previous iterations have the current page listed outside of an anchor tag, with no description to tell users of assistive technologies that the number is the current active page of results.

    An aria-control has been added to the current page to add context for screen-reader users.

    image

    Add aria controls to ellipses that indicate a gap in pages

    In previous iterations, ellipses were used to indicate a gap between pages, where a large number of pages is displayed.

    Aria controls and visually hidden text have been added to the ellipses to indicate the gap in pages to screen-reader users.

    image

    Use aria-controls for previous / next pages

    In previous iterations, the ‘previous’ and ‘next’ links to pages had hidden-from-screen text for screen-reader users (‘previous set of pages’), but still read out the words ‘previous’. Screen readers would therefore read “Previous previous set of pages”.

    Added aria-controls to the previous and next links and made it clear that the previous and next link move to the next page, not the next set, and shortened the number of words declared.

    image

  • Jon-Rowe-HMRC commented 2 years ago

    GDS are now actively working on a pagination pattern, so we’ve paused work on the HMRC version. Comparison of the current draft GDS/HMRC patterns: paginationComparison.pdf

    Our version was almost ready for release, but it makes more sense for a pagination pattern to be part of the main design system.

    Improvements made since our last post:

    Prototype Link: https://hmrc-pagination-prototype.herokuapp.com/ Username: pagination Password: pagination

    Basic:

    Screenshot 2021-12-01 at 10 29 44

    Truncated:

    Screenshot 2021-12-01 at 10 32 52

    First page active:

    Screenshot 2021-12-01 at 10 34 17

    Last page active:

    Screenshot 2021-12-01 at 10 34 47

    Even number of result pages:

    Screenshot 2021-12-01 at 10 35 35

    Code: https://github.com/hmrc/hmrc-frontend/compare/pagination