Skip to content

What's the best pattern for nested traps in the following scenario? #942

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

You must be logged in to vote

Great question! When a second trap is activated, the first one gets paused, which means it stops listening to all the events necessary to detect things like outside clicks. So when the user clicks outside the second (now active) trap, the first trap doesn't know anything about it. But when the second trap gets deactivated from the outside click, the first one will automatically get unpaused. Unpausing a trap will effectively re-activate that trap, and the onActivate() and onPostActivate() hooks (which you can tap into) should get called -- except you won't have a parameter passed to those telling you anything about why the trap is being (re)activated.

So what I would propose you try is to…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@stefcameron
Comment options

@stefcameron
Comment options

@AlexKDawson
Comment options

@AlexKDawson
Comment options

@stefcameron
Comment options

Answer selected by AlexKDawson
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