I'm not able to interact with anything out of the trap #344
-
I would like to know or if this is an expected behavior, but i'm not being able to interact with nothing outside the trap, i just want to trap the focus, i don't want to trap the whole interactivity there, any way to do this with this library? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
That is definitely the expected behavior, hence the name "focus trap"! 😄 That said, there may be a focus-trap option that can help you out here. You could try setting the <FocusTrap
focusTrapOptions={{ allowOutsideClick: true }}
>
{children}
</FocusTrap> Notice you can give a function to the option so that you can further control click behavior when it's outside the trap. |
Beta Was this translation helpful? Give feedback.
That is definitely the expected behavior, hence the name "focus trap"! 😄
That said, there may be a focus-trap option that can help you out here. You could try setting the
allowOutsideClick
option totrue
(it'sfalse
by default), which would allow elements outside the trap to receive mouse clicks. You still won't be able to tab to any element outside the trap, so this won't help disabled users who can't use a mouse, but if that's not a concern, then this might do what you're wanting. Besides, if you allow the tab key to move focus outside the trap, then you don't have a "focus trap" anymore...Notice yo…