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

Improve documentation and consistency in radios and checkboxes components #1847

Merged
merged 5 commits into from
Jul 14, 2020

Conversation

36degrees
Copy link
Contributor

Building on top of #1842:

  • Improve consistency between the radios and checkboxes components
  • Simplify and improve code comments

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1847 June 26, 2020 12:47 Inactive
Base automatically changed from conditional-reveals-back-button to master June 30, 2020 10:40
@36degrees 36degrees marked this pull request as ready for review June 30, 2020 10:40
Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

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

Nice tidy up 👍 I left a couple of small comments.

var $content = this.$module.querySelector('#' + $input.getAttribute('aria-controls'))

if ($content) {
Copy link
Member

Choose a reason for hiding this comment

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

Additional suggestion for increasing consistency: radios have a check $content.classList.contains('govuk-radios__conditional') on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot. I think we were going to do this in #1843 but can include that here now instead.

* Loop over all items with [data-controls]
* Check if they have a matching conditional reveal
* If they do, assign attributes.
**/
Copy link
Member

Choose a reason for hiding this comment

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

Does this comment definitely need removing? It still feels useful to me - maybe excluding the line

Loop over all items with [data-controls]

Or a different solution might be to rename

var target 

to

var conditionalReveal 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it as there's a lot of duplication between this comment and the comments within the callback function.

I've clarified the comments within the function, and I think they cover everything that was in this comment except the fact that it's a loop?

In terms of renaming the variable, the target element that's being associated is probably (hopefully!) a conditional reveal, but I don't think we know that for sure at this point.

Copy link
Member

Choose a reason for hiding this comment

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

As discussed earlier, we could add a general comment to indicate that the JavaScript here sets up the relationship of the aria-controls and conditional reveals.

the target element that's being associated is probably (hopefully!) a conditional reveal, but I don't think we know that for sure at this point.

True. We could have a comment above that line to convey the intention to extract the conditional reveal attribute (but it might not be necessary to add that if we add a comment elsewhere about the relationship).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added JSDoc comments to each function, aiming to explain what the JS is doing.

@hannalaakso I'd value any thoughts or feedback – do you think this addresses your concerns?

Copy link
Member

Choose a reason for hiding this comment

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

Yes the comments and clarified function names are super helpful 👍

@36degrees 36degrees requested a review from hannalaakso July 7, 2020 08:56
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1847 July 7, 2020 08:56 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1847 July 8, 2020 15:24 Inactive
Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

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

Nice clean up and improvement of code comments 🙌

@36degrees 36degrees merged commit 717d054 into master Jul 14, 2020
@36degrees 36degrees deleted the checkboxes-radios-misc-improvements branch July 14, 2020 07:47
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.

3 participants