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

Accordion: Deep links to an anchor in another section do not work if the section is not expanded. #1581

Open
NickColley opened this issue Sep 19, 2019 · 8 comments
Labels
accordion feature request User requests a new feature

Comments

@NickColley
Copy link
Contributor

Hi folks,

A colleague has noticed what appears to be an issue with the accordion pattern: deep links to an anchor in another section do not work if the section is not expanded.

We've encountered the issue specifically on our HMRC content style guide, which uses the GOV.UK Accordion pattern. See, for example, the entry for "duty" linking through to "capitalisation of taxes, duties and levies".

jennifer-hodgson's original comment

@NickColley
Copy link
Contributor Author

NickColley commented Sep 19, 2019

I've had a look at how GOV.UK's Manuals deal with this and they look detect when a link inside a section is focused, then open the section if it is:

https://github.com/alphagov/manuals-frontend/blob/165027be5e39ab84daf9846577389fca32840f33/app/assets/javascripts/modules/collapsible.js#L12

Update: Actually that's not related but will leave this comment for reference.

@NickColley
Copy link
Contributor Author

Is this also going to be an issue with Details, Tabs, Conditional Reveals etc?

@NickColley
Copy link
Contributor Author

I've noticed we do something similar on the design system website to show content:

http://localhost:3000/components/error-message/#options-error-message-example

We should consider making sure that users can disable this code, perhaps by preventDefault() or something?

It may be that we can remove some custom code in the design system website.

@NickColley NickColley added feature request User requests a new feature Effort: days and removed awaiting triage Needs triaging by team labels Oct 23, 2019
@NickColley
Copy link
Contributor Author

It looks like the original team has managed to work around this for now.

We think this could be a complicated fix so we're going to pause our investigation and see if anyone else runs into this issue before prioritising it.

@36degrees
Copy link
Contributor

This is something that GOV.UK are currently adding in their additional accordion JavaScript:

I've added this for consideration for a future 5.x release. I'd suggest we could implement by listening for the hashchange event instead, which would hopefully be performant enough we could enable it by default.

@kelliedesigner
Copy link

There is a need for this in my current prototype at DfE.

We are working on https://www.find-postgraduate-teacher-training.service.gov.uk/

This service allows users to find postgraduate teaching courses in England if they want to teach in a state primary or secondary school, or in further education.

The user need we are exploring is to allow candidates to easily compare courses. This is something which is currently very difficult, as the course pages are long and overwhelming, and contain a lot of duplicate information.

We are currently exploring the use of an accordion to help users navigate the information.

As part of this, we wanted to provide users with a deep link from two sections at the top of the page, one on 'Fees and financial support', and one on 'How placements work'.

We are unable to do this in the current prototype, I can anchor to the accordion section id, but I cannot open the section.

Screenshot 2024-05-22 at 15 28 34
Screenshot 2024-05-22 at 15 28 40

Copy link

Uh oh! @kelliedesigner, the image you shared is missing helpful alt text. Check #1581 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@36degrees
Copy link
Contributor

I think there are two slightly separate things being discussed here:

Opening sections when following a link to a target within a section.

I think this should now 'just work' in Chromium-based browsers because of the use of hidden="until-found" which covers fragment navigation as well as find-in-page:

When an element has the hidden attribute in the hidden until found state, it indicates that the element is hidden like the hidden state but the content inside the element will be accessible to find-in-page and fragment navigation. When these features attempt to scroll to a target which is in the element's subtree, the user agent will remove the hidden attribute in order to reveal the content before scrolling to it.

However, this remains a Chromium-exclusive feature although both Webkit and Mozilla have shown positive signals towards implementing it:

Opening sections by linking directly to a section

I think this is what @kelliedesigner is requesting. This isn't covered by hidden="until-found" and would require us to make changes to the accordion JavaScript to expand sections on page load / hash change.


GOV.UK Publishing Components continue to include additional JavasScript which covers both of these features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accordion feature request User requests a new feature
Projects
None yet
Development

No branches or pull requests

4 participants