We've had an accessibility audit highlight that the cookie consent banner is 'in a strange order' for keyboard navigation. > Issue > • The cookie banner current sits in a slightly odd place in the focus order, > coming after the ‘Advanced Search’ link > • This might be somewhat disorientating for screen reader users. It may also > be frustrating for sighted keyboard users who would like want to dismiss this > prior to exploring the page > > Solution > • Review the order of focus (by tabbing through the page) to ensure the > journey users take through the page and within elements is the most logical > and efficient, and matches the visible order of content > • Move the cookie banner so it can be dismissed as the first action on the > page > • NB – avoid using positive tabindex values to artificially modify the focus > order I've researched this a little and there's evidence that moving the banner to the top is detrimental to engagement. Other research suggests that as soon as a cookie banner appears, it should take the initial keyboard focus. I propose we take the later approach and if the cookie consent banner is present on the page it should take the first focus point until dismissed at which point the focus should be reset.
Created attachment 178786 [details] [review] Bug 39209: Set cookie consent bar as first focus This patch updates the cookie consent javascript, when the feature is enabled, to ensure that the cookie consent bar gets focused when it displays. Test plan 1) Enable the CookieConsent preference 2) Open any OPAC page 3) Hit 'tab' and note the display of 'Skip to main content' 4) Confirm that the cookie consent bar is displayed and continued 'tabs' eventually navigate to it 5) Apply this patch 6) Navigate to any OPAC page 7) Hit 'tab' and note that the 'Cookie consent' bar is focused, your keyboard navigation starts with the cookie consent buttons 8) Accept the essential cookies 9) Hit tab and note the focus is back to normal and shows the 'Skip to main content' button on first keyboard navigation.
Created attachment 178894 [details] [review] Bug 39209: Set cookie consent bar as first focus This patch updates the cookie consent javascript, when the feature is enabled, to ensure that the cookie consent bar gets focused when it displays. Test plan 1) Enable the CookieConsent preference 2) Open any OPAC page 3) Hit 'tab' and note the display of 'Skip to main content' 4) Confirm that the cookie consent bar is displayed and continued 'tabs' eventually navigate to it 5) Apply this patch 6) Navigate to any OPAC page 7) Hit 'tab' and note that the 'Cookie consent' bar is focused, your keyboard navigation starts with the cookie consent buttons 8) Accept the essential cookies 9) Hit tab and note the focus is back to normal and shows the 'Skip to main content' button on first keyboard navigation. Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Thanks for the quick signoff Owen, very much appreciated :)
FAIL koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js FAIL tidiness File is not tidy, please run `perl misc/devel/tidy.pl koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js` if ( $(window).scrollTop() >= wrapper.offset().top + - wrapper.outerHeight() - - window.innerHeight + wrapper.outerHeight() - + window.innerHeight ) { Now that should be tidy. Dont ask me why :)
- document.querySelector('body').setAttribute('tabindex', '-1'); - document.querySelector('body').focus(); - document.querySelector('body').removeAttribute('tabindex'); + document.querySelector("body").setAttribute("tabindex", "-1"); + document.querySelector("body").focus(); + document.querySelector("body").removeAttribute("tabindex"); Also replacing single quotes here. Do we really want that ?
Jonathan Druart: Please see previous two comments.
(In reply to Marcel de Rooy from comment #5) > - document.querySelector('body').setAttribute('tabindex', '-1'); > - document.querySelector('body').focus(); > - document.querySelector('body').removeAttribute('tabindex'); > + document.querySelector("body").setAttribute("tabindex", "-1"); > + document.querySelector("body").focus(); > + document.querySelector("body").removeAttribute("tabindex"); > > Also replacing single quotes here. Do we really want that ? I believe we had some bits where we replaced with double quotes because of a security risk. And for translatable strings there also used to be a coding guideline, so for example French users don't break JS when using ' in their translations. Do you see an issue with the change?
Created attachment 179385 [details] [review] Bug 39209: Set cookie consent bar as first focus This patch updates the cookie consent javascript, when the feature is enabled, to ensure that the cookie consent bar gets focused when it displays. Test plan 1) Enable the CookieConsent preference 2) Open any OPAC page 3) Hit 'tab' and note the display of 'Skip to main content' 4) Confirm that the cookie consent bar is displayed and continued 'tabs' eventually navigate to it 5) Apply this patch 6) Navigate to any OPAC page 7) Hit 'tab' and note that the 'Cookie consent' bar is focused, your keyboard navigation starts with the cookie consent buttons 8) Accept the essential cookies 9) Hit tab and note the focus is back to normal and shows the 'Skip to main content' button on first keyboard navigation. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Amended-by: Jonathan Druart Run tidy.pl
(In reply to Marcel de Rooy from comment #6) > Jonathan Druart: Please see previous two comments. I don't understand. I have run tidy.pl and amended the patch. Now all looks good to me. Only new lines added and the QA script is happy.
Are we happy here at this stage?
Works as advertised (unless you have the "I still don't care about cookies" firedox extension installed, which automatically clicks the least invasive option and thus the consent bar is not shown. So if you have something like that, be sure to disable it before testing...)
Created attachment 180385 [details] [review] Bug 39209: Set cookie consent bar as first focus This patch updates the cookie consent javascript, when the feature is enabled, to ensure that the cookie consent bar gets focused when it displays. Test plan 1) Enable the CookieConsent preference 2) Open any OPAC page 3) Hit 'tab' and note the display of 'Skip to main content' 4) Confirm that the cookie consent bar is displayed and continued 'tabs' eventually navigate to it 5) Apply this patch 6) Navigate to any OPAC page 7) Hit 'tab' and note that the 'Cookie consent' bar is focused, your keyboard navigation starts with the cookie consent buttons 8) Accept the essential cookies 9) Hit tab and note the focus is back to normal and shows the 'Skip to main content' button on first keyboard navigation. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Amended-by: Jonathan Druart Run tidy.pl Signed-off-by: Thomas Klausner <domm@plix.at>
Pushed for 25.05! Well done everyone, thank you!