Replies: 3 comments 1 reply
-
Hi @bdubetink, I'm glad you've found focus-trap useful for your work so far! Have you looked into focus-trap's support for multiple containers (there are many samples to look at, along with links to code in the repo; I just linked to the first one)? Seems like this might solve your main/sub menu issues. |
Beta Was this translation helpful? Give feedback.
-
Hi @stefcameron, Just a quick update to say that the multiple containers was the solution I was looking for and was put in place to resolve my issue! Thanks! |
Beta Was this translation helpful? Give feedback.
-
@bdubetink Awesome! Thanks for reporting back with your experience, and I'm glad it worked! |
Beta Was this translation helpful? Give feedback.
-
Hi,
I used focus-trap on 2 project so far, and I really like how it's work, and it's greatly help me making website more accessible for keyboard users!
There a feature, that I did not found, that are missing for me so fair to make focus-trap perfect and applicable to most the projet I work on.
One example, is a mega-menu. There the main-menu links. When we click on a link, the sub-menu open. At this moment, I want to trap the focus to the sub-menu only. But because in many case, the parent link is not included inside the sub-menu, I cannot navigate to the main link to close the submenu and go throught the other menu link.
In many case, I can't trap the focus to the parent of the link and sub-menu, because there is other links I did not want in the trap.
I think a solution, would be able to add two options for a trap :
extraElements : array, array of element, or selector that is added to the element in the trap. So, if I do a trap for a submenu, I would be able to add the parent link in this array, and then be able to tab throught sub-menu focusable element AND the parent link.
substractElements: array, aray of element, or selector that would be substract to the list of elements that can be focused.
Maybe I misss options that already do one of those things, but I did not find out ? If not, is this something that can be doable / realist to accomplish?
Thanks!
Ben
Beta Was this translation helpful? Give feedback.
All reactions