-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add anchor navigation feature to accordions #1937
Conversation
7e954da
to
1574418
Compare
|
||
This attribute is paired with functionality to automatically open an accordion section on page load where the URL hash is the same as the id of that accordion. [Live example](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/creating-and-updating-pages#associations) | ||
|
||
Unlike with the accordion-wide custom id attribute, this id isn't stored in `localStorage` so does not need to be unique across your domain, but should still be unique to the page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great to mention this unique aspect. I'm wondering if this should be thought about when it comes to the API work.
I'm thinking about the ease of duplicate IDs happening..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails has a thing for generating random values that are unique called SecureRandom
. I don't think it'd be useful here (looks like if no id is passed no id is created) but thought it worth mentioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh thanks @andysellick - good to know, to give some context in a publishing app an ID might be passed to link elsewhere -
## Add associations (tagging) {:#associations}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that there's a lot we still don't know. Manuals publisher might have validation for duplicate ids. This wouldn't surprise me to be honest, it's a feature in Whitehall of all places! I don't think policing data here is a valuable use of time.
app/assets/javascripts/govuk_publishing_components/components/accordion.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive by review, couple of comments/questions. Also I'd suggest squashing your two commits together as they're part of the same change.
|
||
This attribute is paired with functionality to automatically open an accordion section on page load where the URL hash is the same as the id of that accordion. [Live example](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/creating-and-updating-pages#associations) | ||
|
||
Unlike with the accordion-wide custom id attribute, this id isn't stored in `localStorage` so does not need to be unique across your domain, but should still be unique to the page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails has a thing for generating random values that are unique called SecureRandom
. I don't think it'd be useful here (looks like if no id is passed no id is created) but thought it worth mentioning.
app/assets/javascripts/govuk_publishing_components/components/accordion.js
Show resolved
Hide resolved
1574418
to
4663a70
Compare
4663a70
to
cb91159
Compare
@andysellick Done #1941 |
cb91159
to
a611517
Compare
app/assets/javascripts/govuk_publishing_components/components/accordion.js
Outdated
Show resolved
Hide resolved
@@ -5,22 +5,22 @@ | |||
id ||= "default-id-#{SecureRandom.hex(4)}" | |||
items ||= [] | |||
condensed ||= false | |||
anchor_navigation ||= false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flag is a nice halfway.
@@ -274,6 +274,35 @@ examples: | |||
text: "How people read" | |||
content: | |||
html: "<p class='govuk-body'>This is the content for How people read.</p>" | |||
with_the_anchor_link_navigation: | |||
description: | | |||
Some apps require custom ids per accordion section heading for linking between those specific sections, sometimes across multiple pages. An example of this is on manuals pages where multiple manuals will each include large sets of accordions and will reference between specific sections for ease of access to that content. [Live example](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/creating-and-updating-pages#associations). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further to our chat - I think accordions on manuals-frontend
needs more consideration in general. We need to work out how we can do this feature, work out if the API changes can be done.
However for this issue - it's a good fix knowing what we know.
app/assets/javascripts/govuk_publishing_components/components/accordion.js
Outdated
Show resolved
Hide resolved
Update CHANGELOG.md
a611517
to
368f4a0
Compare
- Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Layering on features on-top of Design System Accoridon [1] #1937
- Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Layering on features on-top of Design System Accoridon [1] #1937
Update to follow conventions of GOVUK Frontend 4.0 Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Layering on features on-top of Design System Accoridon - Remove condensed layout, CSS and testing [1] #1937
- Update GOVUK Frontend 4.0 version of Accordion - Layering on GOVUK features on-top of Design System Accordion - Add nodeListForEach, still required - Restore polyfill, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Layering on GOVUK features on-top of Design System Accordion - Add nodeListForEach, still required - Restore polyfill, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Temporarily update to Tabs to resolve testing errors. Part of 4.0 update. [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Temporarily update to Tabs to resolve testing errors. Part of 4.0 update. [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Temporarily update to Tabs to resolve testing errors. Part of 4.0 update. [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Temporarily update to Tabs to resolve testing errors. Part of 4.0 update. [1]#1937
- Update GOVUK Frontend 4.0 version of Accordion - Maintain nodeListForEach, still required - Remove custom CSS for condensed layout, this is not in use on GOVK and goes against Design system Guidance. Additionally the accessibility impact has not been reviewed in depth. - Layering on GOVUK features on-top of Design System Accordion - Maintain existing GemAccoridon features of manuals-frontend that allow a user to navigation through this section. [1] - Temporarily update to Tabs to resolve testing errors. Part of 4.0 update. [1]#1937
What
Applies an optional anchor navigation feature to accordions. This allows anchor links within accordions to:
Additionally fixes a couple of typos in the accordions js and removes a line specifying data_attributes as
nil
. The latter is unnecessary and generates an extranull
attribute on every item on the docs.Why
On manuals, there was previously a function to link between individual sections in manuals for ease of content. This was done by linking via an id anchor and the old bespoke manuals accordion js would work this out and open the accordion. This feature was overlooked in the recent update to manual accordions, leaving a lot of broken links and potentially confusing user journeys across manuals. There's a question to be answered about how accessible this functionality is, however for the moment this PR repairs the bug without having to undo the accordion changes and re-introducing a WCAG 2.3.4 failure.
No visual changes.