-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance: Set passive listener option for use popover scroll to avoid affecting scrolling performance #33478
Conversation
… scrolling performance
Size Change: +18 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
It should only be added on mount for any block UI popovers. Perhaps the warning is logged whenever the event (wheel) listener is called? Not sure why it would be added every time the mouse moves. The event listener is necessary to "scroll through" block UI popovers that are positioned over the editor canvas. I'm not sure about the feature detection unfortunately. Which older browsers are we talking about? |
Mostly IE it looks. Peeking at https://caniuse.com/usage-table I think we should be okay for the block editor. I'd maybe have more concerns if this was being added on a published post view. (Total aside, the official suggested feature detection for this is one of the most awkward I've seen for a DOM spec.) If folks are comfortable with it, we can try merging as is. 👍 |
I think we no longer support IE entirely?
Sounds good. |
Thanks for the review @ellatrix ! |
Setting
{ passive: true }
lets a browser know that we don't intend to callevent.preventDefault
and avoids the need to block scrolling. Without it, scrolling performance may be affected see (https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md and https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners). As a plus, we can also get rid of this annoying warning in chrome :DTwo questions for folks:
Why do we need to add and remove this listener so often as we mouse over elements?
I notice that this the warning is showing up whenever I move my mouse in trunk.
Where is a good spot to put feature detection?
Unfortunately, the object option will be read as
false
on older browser. Mozilla recommends feature detection similar to the following. Is there a good package for this test, or do we already use something like https://modernizr.com/ ?