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

Refactor Details and Button components #761

Merged
merged 8 commits into from
Jun 5, 2018
Merged

Conversation

NickColley
Copy link
Contributor

@NickColley NickColley commented Jun 4, 2018

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

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 () {
Copy link
Contributor Author

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?

Copy link
Contributor

@alex-ju alex-ju Jun 5, 2018

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.

@NickColley NickColley changed the title Refactor details button Refactor Details and Button components Jun 4, 2018
Copy link
Contributor

@alex-ju alex-ju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

// 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)
Copy link
Contributor

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.

Copy link
Contributor

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 NickColley merged commit b4b6dfd into master Jun 5, 2018
@NickColley NickColley deleted the refactor-details-button branch June 5, 2018 11:08
@36degrees
Copy link
Contributor

@NickColley Does this need a changelog entry?

@NickColley
Copy link
Contributor Author

@36degrees yeah, I missed that out, sorry :) PR incoming.

@hannalaakso hannalaakso mentioned this pull request Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants