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 an option to dismiss notifications with ESC instead of minimizing them

See original GitHub issue

I had always thought that pressing ESC had the same behavior as clicking the ‘x’ for the popup “toast” messages, but while investigating an issue with missing telemetry for an experiment we’re doing in CMake Tools, I discovered that pressing ESC after calling vscode.window.showErrorMessage didn’t return a result back to our code nor did it reject the promise. The code just sat there until we shut down the extension host window.

This morning I had a thought that maybe the message had been minimized, and sure enough that’s what it was. This is a problem for extensions that want to log telemetry as a result of a dismissal. Can we get an option in the API to make pressing ESC behave the same as clicking the ‘x’ button in certain toast messages?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
luabudcommented, May 16, 2022

I think we all agree with not changing the default behaviour, it’s more about providing an option to extensions to be able to do something when users press ESC. For example, I have a custom extension with the following code:

 const selection = await window.showErrorMessage(
            'It looks like your Python project has not been set up yet. Would you like us to create a virtual environment and install the dependencies?',
            'Yes, set up project',
            'No, thanks',
        );

When users close the notification, selection gets undefined. But if they press ESC, nothing ever happens (and I think this is what @bobbrow meant by “the code just sat there until we shut down the extension host window.”)

1reaction
isidorncommented, May 13, 2022

@bobbrow thanks for filling the issue. Great discussion. I agree with @digitarald and @daviddossett as that seems like a cleaner solution for this use case.

However with the current API the C++ extension can not do this. Since the showMessage API resolves a promise only once a user dismisses it or chooses a button. So there is not way for an extension to listen to when the user hides all notifications.

fyi @luabud might have ideas on how an extension can figure out if the user hid a notification for experiment purposes.

@bpasero might also have ideas once he returns (in around 2 weeks)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable Esc shortcut to quit Fullscreen - Apple StackExchange
Enter the exact name of the menu item you wish to disable. In this case "Exit Full Screen". Add an alternative keyboard shortcut...
Read more >
Alerts - Presentation - Human Interface Guidelines - Design
An alert gives people critical information they need right away. For example, an alert can tell people about a problem, warn them when...
Read more >
Don't exit full screen when pressing escape in apps like Safari ...
Remember to add e.g. Terminal to the exceptions list — it totally ignores Escape for leaving full screen, but pressing Ctrl-. translates to...
Read more >
How to disable Escape Key for Twitter Bootstrap Modals?
By adding data-keyboard="false" fixes the problem. Something like this: <div class="modal hide fade" data-keyboard="false" role="dialog" ...
Read more >
Support keyboard interaction | Digital Accessibility​
Unless the newly visible content is displaying an error, the user must be able to dismiss that content without moving the mouse or...
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