-
Notifications
You must be signed in to change notification settings - Fork 339
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
Conversation
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.
Nice tidy up 👍 I left a couple of small comments.
var $content = this.$module.querySelector('#' + $input.getAttribute('aria-controls')) | ||
|
||
if ($content) { |
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.
Additional suggestion for increasing consistency: radios have a check $content.classList.contains('govuk-radios__conditional')
on this line.
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.
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. | ||
**/ |
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.
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
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.
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.
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.
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).
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.
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?
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.
Yes the comments and clarified function names are super helpful 👍
65cf399
to
5373696
Compare
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.
Nice clean up and improvement of code comments 🙌
Building on top of #1842: