-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix: support aria-controls with multiple ids in Toogler #11167
Conversation
js/foundation.toggler.js
Outdated
@@ -65,6 +65,21 @@ class Toggler extends Plugin { | |||
'aria-controls': id, |
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.
There is still the old logic left, var id
and others are set multiple times which can cause issues.
It might make more sense to create new variables in the new code block or extend the old logic with the new one.
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.
Quite right! Missed that one. I'll have another look to make sure that I haven't missed anything outside of the changed code. PR coming soon.
I removed the old code, but now I get a failed check. I can't see what I did wrong so could you take a look? |
The Travis test? Well, it seems there was a timeout accessing the Browserstack API in general. I'll try to rerun the test. |
Thanks! |
The Browserstack test successfully ran now. You can also do it by clicking on the retry button. https://travis-ci.org/zurb/foundation-sites/builds/365598109 (you get there by clicking on the green checkmark / red cross next to your commit). |
Thanks. Good to know. |
Hm, why did you close the PR? |
More through inexperience. =) I've only just begun using git and this is my first contribution to open source. I'll study https://foundation.zurb.com/get-involved/code-contributor-guide.html a bit more. |
Ah, your first contribution here. Congrats 🎉 Great that you spotted the issue. So far everything is ok and tests are stilk ok. I'll try to test your changes later. |
Hi @MoarCoding. Thanks for your issue & PR, that's a nice first contribution 🎉! I have a few comments to make about it. I hope it will help you to improve yourself in Git and working on Open Source projects.
And finally, here are some helpful ressources for Git: 📚 |
js/foundation.toggler.js
Outdated
|
||
//make sure not to duplicate id in aria-controls | ||
$this.attr({ | ||
'aria-controls': `${$this.attr('aria-controls') ? $this.attr('aria-controls').replace(id, '') : ''} ${id}`.trim(), |
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 would actually remove test1
inside id="test15 test25"
and change it to id="5 test25 test1"
. You should use RegExp instead with the boundary special character \b
.
js/foundation.toggler.js
Outdated
'aria-expanded': this.$element.is(':hidden') ? false : true | ||
var id = this.$element[0].id, | ||
$triggers = $(`[data-open~="${id}"], [data-close~="${id}"], [data-toggle~="${id}"]`), | ||
that = 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.
Foundation uses Babel, so you can use all ES2015 features like arrow functions. See https://github.com/lukehoban/es6features
I think this part could be cleaned a bit. I'll take care of this.
…ibute Changes: * Only add the id if it does not exist in `aria-contolers` with better RegExp detection * Use ES6 features to simplify code * Add comments
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.
@MoarCoding I took care of the requested changes. Please let me know what you think about it ;)
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.
works very good, did not see any issue
Thanks, @ncoden! I'll make sure to tick those boxes when submitting my next PR. |
Closes #11166
-- edited by @ncoden