orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js
https://playground.cookieconsent.orestbida.com/
MIT License
3.91k stars 407 forks source link

[Feat]: disable trap focus #551

Closed straatrakker closed 1 year ago

straatrakker commented 1 year ago

Description

Maybe it would be useful to be able to disable the focus trap. This could be useful for when you have a page with details about the cookies on your website. Now it's not possible to tab through this information without first accepting or declining the cookies. This is not accessible

Proposed solution

No response

Additional details

No response

dombyte commented 1 year ago

Do you mean disablePageInteraction?

straatrakker commented 1 year ago

@dombyte No I don't think that's what i am looking for. In the source code there is a function called _handleFocusTrap().

So when the cookie consent modal is shown, i cannot tab anywhere besides the cookie consent modal.

I would like to be able to disable handleFocusTrap(). Because I want the users of my website to still be able to tab through the webpage while the cookie consent modal is shown

dombyte commented 1 year ago

But that's possible when you set disablePageInteraction = false Then the Modal is shown and you're still able to navigate the Page.

straatrakker commented 1 year ago

@dombyte To the best of my knowledge disablePageInteraction adds a dark overlay and blocks the interaction with the page. By default disablePageInteraction is set to false.

I have set disablePageInteraction to false. I can indeed interact with the page. I can scroll on the page, and i can navigate the page with my cursor/mouse. But what I can not do is interact with the page using the tab button. The tab focus is trapped inside the modal and cannot leave.

I do think that this behavior is most common, but in my case I do have to tab out of the modal.

dombyte commented 1 year ago

Ah my mistake, I understood you wrong. Yeah that's indeed them something else.

straatrakker commented 1 year ago

Ah my mistake, I understood you wrong. Yeah that's indeed them something else.

No worries, I appreciate your time :)

orestbida commented 1 year ago

Now it's not possible to tab through this information without first accepting or declining the cookies. This is not accessible

Hi @straatrakker, the current behavior follows a11y best practices https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/dialog/.

To me this looks more like a personal preference; sorry this won't be worked on!