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

Click Away Directive Fires on First Load #17

Open
godismyjudge95 opened this issue Dec 8, 2021 · 0 comments
Open

Click Away Directive Fires on First Load #17

godismyjudge95 opened this issue Dec 8, 2021 · 0 comments

Comments

@godismyjudge95
Copy link

It seems the following should work but it does not:

<button @click="show = true">
<input v-if="show" v-if-click away="show = false" />

This works:

<button @click="show = true">
<input v-if="show" @blur="show = false" />

The reason why the former doesn't work is because the click away code is evaluated immediately when the element is mounted.
This should not be the case and can be resolved by wrapping the code inside the directive with a closure:

<button @click="show = true">
<input v-if="show" v-if-click away="() => show = false" />

It would be nice if this could be done internally so one doesn't have to remember this hack around the issue.

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