[Toast] Ability to remove `document` event listeners
See original GitHub issueFeature request
Overview
Currently, the Toast package adds an event listener to the document for managing hotkeys internally.
I’d like the ability to disable this so that I have full control over Toast hotkey handling. One option would be simply passing an empty array to the hotkeys prop. Ideally, Toast would check the length of the hotkey prop before adding an event handler to document and, if hotkey was length 0, then no handler would be added.
Note: the hotkey listeners were implemented using Array#every() which returns true for an empty array.
Who does this impact? Who is this for?
Users of the Toast package.
Additional context
In my application, I have a sophisticated, custom service which is responsible for handling all hotkeys. I’d like to manage toast hotkeys that way.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
EventTarget.removeEventListener() - Web APIs | MDN
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.
Read more >How to handle standard toast events in LWC
Is there a way to capture standard toasts in lwc? constructor() { super(); document.addEventListener('lightning__showtoast', this.
Read more >window.addEventListener not triggered by simulated events
The first component I tried to test using this was a mixin for detecting clicks outside a component. In order to do this...
Read more >Removing an anonymous event listener - Stack Overflow
The easiest way to remove all event listeners for an element is to assign its outerHTML to itself. What this does is send...
Read more >Lightning Web Component(LWC) Toast Messages - SfdcPoint
Lightning Web component LWC Toast Messages.LWC can send a toast notification that pops up to alert users of success, error or warning.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

No you’re right, it’s just that in other places some of these cancellable events we have are custom events we raise, so those wouldn’t affect any other events. In this case we are piggy-backing on the keyboard event so it would.
oh, was that a mistake on our part? seems it should be a
CustomEventno?