monaco-editor version: 0.14.6
Browser: Chrome
OS: macOS
I noticed that Chrome's dev tools in verbose mode includes a handful of identical warnings when loading Monaco:
[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
I'm not sure if there's an intentional reason why these event listeners aren't passive or if it was just an oversight, but I thought I'd surface it in case others also hadn't noticed these warnings.
This is intentional. The editor uses those events to paint only the current visible viewport of the editor.
Is it a bug in Chrome that it warns on these?
It is a hint that Chrome shows to developers that introduces a new possibility (at the time) for scroll listeners, with the passive flag. I have seen the hint, am aware of it, but our use-case is valid and we cannot use the passive flag. I don't know if there is a way to explain that to Chrome to have it not print these messages anymore.
You can avoid the warning if the code that adds the event listener actually specifies passive: true or passive: false. If the passive attribute is set either way it will not warn.
Had a chat with Nzolghadr@chromium, we can change the link to the explainer which has more information:
https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
Most helpful comment
You can avoid the warning if the code that adds the event listener actually specifies passive: true or passive: false. If the passive attribute is set either way it will not warn.