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

Suggestion:Change event listening to document from click to mousedown or mouseup. #55

Open
jsnb2333 opened this issue May 29, 2024 · 2 comments

Comments

@jsnb2333
Copy link

The reason is that the event firing order of mousedown and mouseup is before the click event. This can avoid race problems very well.

The core function is implemented by bubbling to document, so if the user acts on the external element of v-onclickaway through the set click event, the trigger time will always be earlier than the trigger of the v-onclickaway callback function. This will cause if the user's click event callback and v-onclickaway callback modify the same state (there is a race problem), then the final result is always the modified result of the v-onclickaway callback (this is not desirable, because v-onclickaway callbacks are usually basic behavior, and the user's click priority should be higher than the basic behavior).

Please refer to https://github.com/ElemeFE/element/blob/dev/src/utils/clickoutside.js practice

@jsnb2333
Copy link
Author

#10 Also affected by this behavior

@jsnb2333
Copy link
Author

For example, v-onclickaway acts on the dialog to close the dialog. When the dialog external element registers the click event to open the dialog, the dialog will never be opened.

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

No branches or pull requests

1 participant