ember-basic-dropdown icon indicating copy to clipboard operation
ember-basic-dropdown copied to clipboard

Touch and wheel events are missing passive flag

Open sebastianhelbig opened this issue 5 years ago • 4 comments

It is best practice to add the passive flag to every wheel, mousewheel, touchstart, and touchmove event listener that does not call preventDefault()

See: https://developers.google.com/web/tools/lighthouse/audits/passive-event-listeners

Currently Lighthouse complains at this minified line:

r&&!1===r(t,e)||(13===e.keyCode?t.actions.toggle(e):32===e.keyCode?(e.preventDefault(),t.actions.toggle(e)):27===e.keyCode&&t.actions.close(e))}}},_touchMoveH
andler:function(){this.hasMoved=!0,document.removeEventListener("touchmove",this._touchMoveHandler)},stopTextSelectionUntilMouseup:function(){document.addEven
tListener("mouseup",this._mouseupHandler,!0),document.body.classList.add("ember-basic-dropdown-text-select-disabled")},addMandatoryHandlers:function(){var e=t
his

sebastianhelbig avatar Jun 30 '19 16:06 sebastianhelbig

Came here to report this. If I visit https://ember-basic-dropdown.com/ in Chrome I get [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive in the console.

I think adding passive=true inside the on modifier at https://github.com/cibernox/ember-basic-dropdown/blob/2e76702d02cceab841a88d2119318d2dbbc97419/addon/templates/components/basic-dropdown-trigger.hbs#L15 will get rid of the warning.

luketheobscure avatar Jan 23 '20 21:01 luketheobscure

Any updates on this? @luketheobscure could you submit PR with suggested changes?

xomaczar avatar Sep 23 '20 13:09 xomaczar

I believe that in this case they do have to be active. Passing passive=false would silence the warning?

cibernox avatar Sep 23 '20 13:09 cibernox

It did for me - not sure why I am not seeing the same chrome warnings on doc site?

xomaczar avatar Sep 23 '20 16:09 xomaczar