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

Usagov 1949 report issue incorrect tab order #1984

Merged
merged 9 commits into from
Oct 2, 2024
24 changes: 24 additions & 0 deletions web/themes/custom/usagov/scripts/iframeTabindex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Improve the accessibility of pages that use recaptcha.
* Adding a tabindex attribute to an iframe in the recaptcha for the correct tabbing order
* Used on pages: report a website issue in English and Spanish
*/


// checks to see if the page has loaded
function winLoad(callback) {
"use strict";
if (document.readyState === 'complete') {
callback();
}
else {
window.addEventListener("load", callback);
}
}

// adds the attrubute to the iframe once the page is loaded
winLoad(function() {
"use strict";
const iframe = document.querySelector("iframe");
iframe.setAttribute("tabindex", "1");
});
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://www.google.com/recaptcha/api.js?hl=es" defer></script>
{{ attach_library('usagov/iframeTabindex') }}
{{ attach_library('usagov/reportAProblem') }}
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,6 @@

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://www.google.com/recaptcha/api.js"></script>
{{ attach_library('usagov/iframeTabindex') }}
{{ attach_library('usagov/reportAProblem') }}

4 changes: 4 additions & 0 deletions web/themes/custom/usagov/usagov.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ lazyLoadBgImage:
modal:
js:
scripts/modal.js: {}

iframeTabindex:
js:
scripts/iframeTabindex.js: {}
Loading