alphagov / govuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
https://frontend.design-system.service.gov.uk/
MIT License
1.14k stars 319 forks source link

Details expanded state is not announced by iOS VoiceOver #2349

Open 36degrees opened 2 years ago

36degrees commented 2 years ago

Description of the issue

As flagged by @mcheung-nhs, the expanded state of the details component is not announced by VoiceOver when the element is opened on iOS

Steps to reproduce the issue

  1. Open https://design-system.service.gov.uk/components/details/default/index.html on an iPhone
  2. Enable VoiceOver (VO)
  3. Focus 'Help with nationality'
  4. Double tap to expand the element
  5. Swipe forward into the content
  6. Swipe backwards to the summary

Expected behaviour

Actual behaviour

Although VO announces the element as collapsed in step 3, it does not announce the expanded state.

Environment (where applicable)

36degrees commented 2 years ago

This appears to be related to the use of display: inline-block on the <summary>.

I've raised a bug with WebKit – https://bugs.webkit.org/show_bug.cgi?id=230408

Not sure if there's anything we can do to mitigate this from our side? Without display: block the clickable area and focus state expand to fill the parent:

Screenshot 2021-09-17 at 15 24 03

querkmachine commented 9 months ago

The latest version of Safari Technology Preview (version 183) has resolved a number of accessibility issues relating to the details/summary elements. This issue may be resolved in the next Safari version.

https://bugs.webkit.org/show_bug.cgi?id=108979 https://bugs.webkit.org/show_bug.cgi?id=263499

querkmachine commented 2 months ago

The WebKit team mentioned making accessibility improvements to a bunch of elements (details included) in their WWDC blog post last week. I've hopped onto the iOS 18 developer beta and tested how various implementations of details/summary currently work in that version.

Default details/summary element

A basic, unstyled details/summary element by itself on an otherwise empty webpage.

GOV.UK Design System component

The currently live example on the Design System website.


It seems that WebKit now applies the button role to summary elements, which may resolve some of the issues with interaction and recognition of the control by assistive technologies.

This would seem to support the theory that inline-block styling is for some reason preventing the state from being properly announced.

romaricpascal commented 2 months ago

Random thought about the display: could it be worth trying other 'shrink to fit' values of display like:

Also wondering if we could check with designers if it's that bad that the focus is full width (we might have some history about the decision, though).

36degrees commented 2 months ago

I've got a proof of concept locally that just uses display: block with float: left on the summary and it seems to solve the issue in iOS… haven't tested anything else yet.

width: fit-content is a good shout to explore too.