Skip to content

I'm not able to interact with anything out of the trap #344

Answered by stefcameron
martinmunillas asked this question in Q&A
Discussion options

You must be logged in to vote

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 to true (it's false 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...

<FocusTrap
  focusTrapOptions={{ allowOutsideClick: true }}
>
  {children}
</FocusTrap>

Notice yo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@martinmunillas
Comment options

@stefcameron
Comment options

Answer selected by stefcameron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants