This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fixes two issues: | |
// - Clicking a link with a `phx-click` attribute did not cause the link default (navigation) to trigger. | |
// - Clicking a button inside the link *would* cause the link default to trigger. | |
Hooks.AllowLinkDefaultAndPreventNestedDefault = { | |
mounted() { | |
this.el.addEventListener("click", (e) => { | |
// `closest` in case we click an element inside a button, e.g. an icon. | |
if (e.target.closest("button")) { | |
e.preventDefault() | |
} else { |