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

using data-parsley-trigger="blur" stop 'click event' from being executed #1360

Open
1 task done
pkc112 opened this issue Aug 26, 2021 · 2 comments
Open
1 task done
Labels

Comments

@pkc112
Copy link

pkc112 commented Aug 26, 2021

What kind of issue is this? (put 'x' between the square brackets)

https://codepen.io/code-prashant/pen/RwgPaQV?editors=101

once the codepen loads keep focus in Please enter a palindrome: field
now scroll and click on 'click me link'

issue: alert not fired.
click again and alert is fired

@marcandre
Copy link
Collaborator

Convincing demo, thank you. I agree this is a bug. I've spent 45 minutes in the code trying to figure out the reason and I can't find it.

A shorter demo (no js needed):

<form data-parsley-validate="" data-parsley-focus="none" data-parsley-trigger="blur">
  <label>Click in here first:</label>
  <input type="text" name="s" required="">

  <input type="submit">
</form>
<div onclick="alert('on click filred')">then click me twice</div>

I don't understand how Parsley can be interrupting the click event (it doesn't listen to it). I turned off the auto-focus, just to be sure, same effect.

@marcandre marcandre added the bug label Aug 26, 2021
@fmeyertoens
Copy link

This doesn't seem to be a bug. The click event is fired when the mouse is

both pressed and released while the pointer is located inside the element.

https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event
Because the validation happens when you click the div and the input loses focus, the appearing error message causes a layout shift. Therefore the mouse isn't released on the div anymore and no click event is fired. You can easily test this by making the div so large that your mouse stays inside it, even when the error message appears. Then the click event is fired and the alert is shown.

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

No branches or pull requests

3 participants