-
Notifications
You must be signed in to change notification settings - Fork 335
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
Refactor Details and Button components #761
Conversation
Since we encourage users to load their JavaScript before the `<body>` tag, these listeners are not necessary, if a user wants to load GOV.UK Frontend when the page loads. They could wrap their own initialisation of the Details component with a similar listener.
Now if a user chooses only certain details elements will be enhanced.
These are replaced by our polyfills
// Used to generate a unique string, allows multiple instances of the component without | ||
// Them conflicting with each other. | ||
// https://stackoverflow.com/a/8809472 | ||
export function generateUniqueID () { |
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.
Is there a simpler version of this?
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.
It may be a bit of an overkill for what we need, but I get is trying to follow rfc4122, so it should be ok.
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.
💯
src/components/details/details.js
Outdated
// Add ARIA role="group" to details | ||
details.setAttribute('role', 'group') | ||
// Save shortcuts to the inner summary and content elements | ||
$module.__summary = $module.getElementsByTagName('summary').item(0) |
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.
Not a blocker and I know they were already there, but we're using double underscores only on this component when storing references.
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.
Forget about that, you already changed it in the next commit.
@NickColley Does this need a changelog entry? |
@36degrees yeah, I missed that out, sorry :) PR incoming. |
Updates the Details and Button to match the other components, so they initialise individually.
Best viewed commit by commit
Fixes #666
Testing
Details
Path: /components/details/preview
Tested: click, space and enter
IE8: Works
IE9: Works
IE10: Works
IE11: Works
Edge 17: Works
Firefox 60: Works
Chrome 66: Works
Safari 11.1: Works
Button
Path: /components/button/start-link/preview
Tested: space
IE8: Works
IE9: Works
IE10: Works
IE11: Works
Edge 17: Works
Firefox 60: Works
Chrome 66: Works
Safari 11.1: Works