If you're looking for a solution, consider replacing the .prevent
event modifier with a direct call to event.preventDefault()
in your event handler:
<a
href="#"
class="modal-overlay"
aria-label="Close"
v-on:click="maybeCloseModal"
/>
You can define a method like maybeCloseModal
in your methods
section to handle this logic:
maybeCloseModal: function (event) {
if (this.overlayClickClosesModal) {
event.preventDefault();
this.closeModal();
}
}
In your case, it might be worth considering whether clicking the link has any useful default behavior. If not, you could unconditionally prevent it by modifying the link as follows:
<a
href="#"
class="modal-overlay"
aria-label="Close"
v-on:click.prevent="overlayClickClosesModal && closeModal()"
/>
You may also want to make the aria-label
attribute conditional based on the same boolean flag or use v-if
to toggle between clickable and non-clickable overlays.