I am working on a project that has cart functionality. There's a button that opens or closes a cart. It's an overlay with position: fixed
. So, if I am tabbing through the interactive elements and then click on the open cart button, the cart gets opened. The cart container element has a hidden
class that gets toggled on click
and keyup
events.
But if I press tab
again after that, I can't navigate inside the cart. Instead, the screen moves to the next interactive element on the page. I have tried moving the focus to the cart content using the Element.focus()
and Element.click()
APIs, but they don't solve this issue. If I want to tab through the interactive elements of the cart, then the only way to do this is to click on it manually.
So, how can I make the cart content accessible through tab navigation when the button gets clicked or the Enter
key gets pressed?