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

[Bug]: Focus lost after Accept / Reject #475

Closed
5ulo opened this issue Feb 19, 2023 · 4 comments · Fixed by #486
Closed

[Bug]: Focus lost after Accept / Reject #475

5ulo opened this issue Feb 19, 2023 · 4 comments · Fixed by #486
Labels
bug:confirmed bug Something isn't working
Milestone

Comments

@5ulo
Copy link

5ulo commented Feb 19, 2023

Expected Behavior

When CC window is closed on Accept / Reject etc. and you hit TAB key one more time, you should be focused on the first focusable element inside the website.

Current Behavior

After closing the CC window and hitting TAB key again, focusing starts after the website content - the focus is shifted to browsers UI elements like tabs, status bar etc.. see attached video. Can't access website content. This is a huge accessibility failure. This bug is in Chromium based browsers (Chrome, Vivaldi, Opera..), also in Safari.
Firefox works as expected - hitting TAB focuses the first focusable element.

DEMO:
https://codepen.io/5ulo/pen/JjaYZNv

Chrome - navigating with tab key
https://user-images.githubusercontent.com/4980919/219949890-4efc40c2-1834-4d0f-ae5b-9b4a3be55b3a.mp4

Firefox - navigating with tab key - working
https://user-images.githubusercontent.com/4980919/219949894-393da0d8-b9d7-4230-84a5-16fa8729ae23.mp4

Steps to reproduce

As seen in codepen example

Proposed fix or additional info.

No response

Version

2.8.9, 3 alpha

On which browser do you see the issue?

Chrome

@5ulo 5ulo added the bug Something isn't working label Feb 19, 2023
@orestbida orestbida added this to the v3.0.0-rc.14 milestone Feb 20, 2023
@orestbida
Copy link
Owner

Thank you for the sweet issue!

@orestbida orestbida modified the milestones: v3.0.0-rc.14, v2.8.10 Feb 20, 2023
@5ulo
Copy link
Author

5ulo commented Feb 21, 2023

More info to this: After closing CC window the focus jumps at the very end of html, so next TAB move jumps out of the website to the closest UI.
Proof of this feature is closing the CC window and hitting SHIFT + TAB which moves focus on the very last focusable item in HTML DOM.

@orestbida orestbida linked a pull request Mar 15, 2023 that will close this issue
orestbida added a commit that referenced this issue Mar 15, 2023
Fix lost focus when modal is hidden (close #475)
@orestbida orestbida modified the milestones: v2.8.10, v2.9.0 Mar 15, 2023
@waako
Copy link

waako commented Jun 12, 2023

The fix introduced in #486 seems to have been lost in v2.9.0 and beyond.

The main_container is still being appended at end of body, therefore causing other issues.
For example, when using NVDA screenreader (on Windows with Chrome) the initial focus is not on cookie consent modal, it takes several tabs to get there.

Ensuring main container is appended before first child of root/body resolves these sort of issues.

@5ulo
Copy link
Author

5ulo commented Nov 2, 2023

This should not be closed as the bug is still there.
(root || document.body).appendChild(main_container);
It should have insertBefore at the beginning of the body or root so user does not loose focus inside page after consent.
Would be great to have this behaviour optional:

position: 'before|after'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:confirmed bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants