question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `allowEscape` or another event to handle escape without deactivation

See original GitHub issue

How do you feel about adding allowEscape to complement escapeDeactivates, similar to the clickOutsideDeactivates/allowClickOutside pair?

I have a use case where I want to navigate to a different page when the user clicks outside or hits escape inside a modal. If the user cancels navigation, the modal should remain open and the focus trap should remain in effect. If allowEscape existed, I could achieve the behavior with the following options:

{
    clickOutsideDeactivates: true,
    escapeDeactivates: true,
    allowClickOutside: () => {
        window.location.href = 'https://www.example.com/';
        return true;
    },
    allowEscape: () => {
        window.location.href = 'https://www.example.com/';
        return true;
    }
}

Another option would be to add onClickOutside and onEscape events that are invoked regardless of clickOutsideDeactivates and escapeDeactivates properties. The configuration would be:

{
    clickOutsideDeactivates: false,
    escapeDeactivates: false,
    onClickOutside: () => window.location.href = 'https://www.example.com/',
    onEscape: () => window.location.href = 'https://www.example.com/'
}

In any case, I’m happy to send a pull request with the implementation if I can get an agreement on what the API should look like.

Edit: Added another example.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stefcameroncommented, Jul 1, 2021

This is being published in 6.6.0 right now.

1reaction
stefcameroncommented, Jun 28, 2021

I opened #442 to fix this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Special condition for battle escape :: RPG Maker VX Ace ...
I set the item properties to allow escape but how can I setup the after escape effect (preferably without scripts)?
Read more >
How to disable Escape Key for Twitter Bootstrap Modals?
If I focus on an input field (any field for that matter) and press ESC key, that modal is hidden. However, if I...
Read more >
Escape From X-Chromosome Inactivation: An Evolutionary ...
This process transcriptionally silences all but one X chromosome in each female cell, although 15–30% of human X-linked genes still escape ...
Read more >
4.23 Toxins of Biological Origin (Biotoxins) - Handling and ...
Primary containers of the toxin should be non-breakable if possible, and vials should be maintained in a closed secondary container that will not...
Read more >
Duxbury Braille Translator for Windows (Version 11.3 ...
The DuxUser forum is an Internet email listserv that is open to Duxbury users, ... The Duxbury Shared License Service is not added...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found