Skip to content
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

Violation error Added non-passive event listener to a scroll-blocking #12822

Closed
JokerMartini opened this issue Mar 16, 2022 · 39 comments
Closed

Comments

@JokerMartini
Copy link

What happened?

Created a new project and noticed that it produces tons of errors 'Added non-passive event listener to a scroll-blocking'. I'm not sure why this would be. I'm using the latest version of quasar for this project as of today it's the latest.

What did you expect to happen?

I dont expected to see so many errors.

Reproduction URL

Not applicable

How to reproduce?

  1. Create a new project with cli
  2. Run the project in dev electron
  3. Check chrome console

Flavour

Quasar CLI with Webpack (@quasar/cli | @quasar/app-webpack)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite), Electron Mode

Platforms/Browsers

Electron

Quasar info output

No response

Relevant log output

No response

Additional context

No response

@github-actions
Copy link

Hi @JokerMartini! 👋

It looks like you provided an invalid or unsupported reproduction URL.
Do not use any service other than Codepen, jsFiddle, Codesandbox, and GitHub.
Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc.
Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

@robfordww
Copy link

image

I can confirm the same issue on a pretty new and basic app:
» Dev mode............... spa
» Pkg quasar............. v2.6.0
» Pkg @quasar/app-vite... v1.0.0-beta.3
» Browser target......... edge99|chrome99

@philippedasilva-orizone

Hi, I'm getting this same issue and its repro is so simple to see: just open QBtn component page in the official Quasar documentation and you'll see a bunch of them in the console (verbose required).

From my quick research, I believe it has been introduced after this bug was reported: #12385
And @rstoenescu solved it with this commit: 672ed26

I believe it then generated this bug.

@pdanpdan
Copy link
Collaborator

So many comments and not even one that specifies OS/Browser + version

@philippedasilva-orizone

So many comments and not even one that specifies OS/Browser + version

In my case, I noticed it on my Macbook Air M1 running MacOS Monterey 12.3 on Chrome 99.0.4844.74

@pdanpdan
Copy link
Collaborator

Because I cannot reproduce it on chrome dev on Linux and windows.
And on desktops it should not listen for touch events.

@philippedasilva-orizone

Because I cannot reproduce it on chrome dev on Linux and windows. And on desktops it should not listen for touch events.

I'm sorry but I just tried on Chrome 99.0.4844.82 on Windows (11) and I get the same warnings on the console (make sure to enable Verbose logging in the console to see them). If not, try a quick full refresh on the page as sometimes, I noticed that on first load, they do not appear somehow...

@JokerMartini
Copy link
Author

I get this on windows desktop
Operating System - Windows_NT(10.0.19042) - win32/x64
NodeJs - 14.17.0

@pdanpdan
Copy link
Collaborator

Ok, I found it, it's just on Qv2 because on Qv1 the listener is only attached when the device has touch.

But this is just a cosmetic difference, the main problem is that in order to allow preventing the touch event the listener must not be passive.

Maybe a way would be to check if there is a listener attached on QBtn and only the use non passive.

@philippedasilva-orizone

Hi @pdanpdan could you point out where we should look at in the code so we can eventually submit a PR ? ;) thanks

@pdanpdan
Copy link
Collaborator

In here:

But I don't understand the root cause of the problem, because in Qv1 I don't get the warnings.

@philippedasilva-orizone

I don't know either but I strongly believe it is related to the commit I mentioned previously in order to solve a bug: it seems to me that it shows that we are replacing OnTouchstartPassive to OnTouchstart

@robert-hoffmann
Copy link
Contributor

Definitely related to the q-btn

All pages that have a q-btn produce this error upon display

@JokerMartini
Copy link
Author

Yeah this error still exists in all quasar projects i've been creating

@Sfinx
Copy link

Sfinx commented May 12, 2022

Same here, Desktop Ubuntu 20.04 (no touch there !) , Chrome 101.0.4951.64 (Official Build) (64-bit), Quasar v2.6.6

@thomas-topway-it
Copy link

I'm also experiencing this error, on desktop, Linux, Quasar v2.7.1, it shows up only when the component/app is updated, not on loading, this could be related to the following piece of code

const onEvents = computed(() => {
  if (props.loading === true) {
    return {
      onMousedown: onLoadingEvt,
      onTouchstartPassive: onLoadingEvt,
      onClick: onLoadingEvt,
      onKeydown: onLoadingEvt,
      onKeyup: onLoadingEvt
    }
  }

  if (isActionable.value === true) {
    return {
      onClick,
      onKeydown,
      onMousedown,
      onTouchstart
    }
  }

(QBtn.js)

@209
Copy link

209 commented Aug 10, 2022

Guys, could you fix it?)

Снимок экрана 2022-08-10 в 23 37 43

@RobbeVorsselmans
Copy link

I'm still having this same problem...

Windows 10 Pro, no touchscreen, node v16.15.1, quasar v2.7.7

@Sazzels
Copy link

Sazzels commented Sep 17, 2022

I am also experiencing this warning.

"node_modules/quasar": {
      "version": "2.8.3"

@Carleslc
Copy link

Same warnings in my Macbook Pro 2016, macOS Monterey 12.5.1, Chrome 104.0.5112.101
SPA quasar v2.8.3

pdanpdan added a commit to pdanpdan/quasar that referenced this issue Sep 23, 2022
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Sep 30, 2022
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Sep 30, 2022
rstoenescu added a commit that referenced this issue Oct 1, 2022
* feat(touch events): use passive mode in more cases #12822

* Update TouchPan.js

* Update TouchSwipe.js

Co-authored-by: Razvan Stoenescu <razvan.stoenescu@gmail.com>
@rstoenescu
Copy link
Member

Fixed in cb2c64d for Qv2.

Fix will be available in v2.8.5 and v1.21.0

@RobbeVorsselmans
Copy link

Thanks a lot!

@fardolieri
Copy link

Looks like this warning is still showing up whenever a QBtn with a loading prop is clicked. Is this expected?

@imvenx
Copy link

imvenx commented Feb 8, 2023

Looks like this warning is still showing up whenever a QBtn with a loading prop is clicked. Is this expected?

Having same problem :loading prop is still giving warning.. in the meanwhile, any workaround that don't involve v-if/v-else?

image

Fixed in cb2c64d for Qv2.

Fix will be available in v2.8.5 and v1.21.0

@pdanpdan
Copy link
Collaborator

pdanpdan commented Feb 8, 2023

You know, there are situations when that warning means exactly what it says.

@imvenx
Copy link

imvenx commented Feb 8, 2023

You know, there are situations when that warning means exactly what it says.

?
It should be a way to set :loading event to passive

@pdanpdan
Copy link
Collaborator

pdanpdan commented Feb 8, 2023

It's a warning to check if what you did has a reason or not (in this case adding a non passive listener). And if you need to prevent default you need non passive

@imvenx
Copy link

imvenx commented Feb 8, 2023

It's a warning to check if what you did has a reason or not (in this case adding a non passive listener). And if you need to prevent default you need non passive

yes, we need a way to set that event to passive, no point on having non passive loading event on btn by default.

@pdanpdan
Copy link
Collaborator

pdanpdan commented Feb 8, 2023

You mean you want the button to be still active while loading? Then just replace the content with a loading indicator

@imvenx
Copy link

imvenx commented Feb 8, 2023

You mean you want the button to be still active while loading? Then just replace the content with a loading indicator

I mean exactly what OP means but for loading

@pdanpdan
Copy link
Collaborator

pdanpdan commented Feb 8, 2023

To summarize:

  • if you want the button in loading state to not be active then the listeners must be not-passive (quasar behavior for l ii adding prop)
  • if you want a button that is active but shows a loading indicator then change the content of the button to show a loading indicator

@imvenx
Copy link

imvenx commented Feb 8, 2023

To summarize:

* if you want the button in loading state to not be active then the listeners must be not-passive (quasar behavior for l ii adding prop)

* if you want a button that is active but shows a loading indicator then change the content of the button to show a loading indicator

idk what you mean, If I create literally a <q-btn loading /> component I get this warning, to me that looks like a bug, it should be a way to at least do loading.passive

@imvenx
Copy link

imvenx commented Feb 8, 2023

To summarize:

* if you want the button in loading state to not be active then the listeners must be not-passive (quasar behavior for l ii adding prop)

* if you want a button that is active but shows a loading indicator then change the content of the button to show a loading indicator

btw I did the button with a spinner inside on v-slot and still get warning message, idk if that's what you were saying, the only way to get around it is to do v-if/else with spinner instead of using loading, but that defeats the whole point of having a loading prop.

@pdanpdan
Copy link
Collaborator

pdanpdan commented Feb 8, 2023

Don't use the loading prop - use your own way to determine if it is loading
Make a codepen, please

@imvenx
Copy link

imvenx commented Feb 8, 2023

Don't use the loading prop - use your own way to determine if it is loading Make a codepen, please

Forgot to mention that this bug only happens on electron, so can't make codepen

gpizzorno added a commit to DALME/DALME-Online-Database that referenced this issue May 29, 2023
Error in question is "Violation error Added non-passive event listener to a scroll-blocking", bug: quasarframework/quasar#12822
@Download
Copy link

Ok, I found it, it's just on Qv2 because on Qv1 the listener is only attached when the device has touch.

But this is just a cosmetic difference, the main problem is that in order to allow preventing the touch event the listener must not be passive.

Maybe a way would be to check if there is a listener attached on QBtn and only the use non passive.

If you need the event to be non-passive, indicate so using the third parameter (set it to true I think). The warning is not about not using passive event handler, but about not using the third parameter to specify whether the event handler is passive or not. If you don't specify the third parameter, the browser will assume the event is non-passive and print this warning. If you specify the third parameter, the warning will disappear.

@Download
Copy link

Getting this warning with Quasar

"quasar": "^2.16.4",
"nuxt-quasar-ui": "^2.1.2",

On a MacBook Pro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.