rgossiaux / svelte-headlessui

Unofficial Svelte port of the Headless UI component library
https://svelte-headlessui.goss.io
MIT License
1.78k stars 96 forks source link

Fix: <a/> links not working properly in <Dialog/> #178

Open JorensM opened 6 months ago

JorensM commented 6 months ago

This PR fixes an issue where clicking on an <a/> element that is inside a <Dialog/> caused a full page reload due to the fact that <Dialog/> had a click handler that called e.stopPropogation(). <a/> elements have a native Svelte event handler attached to them, which was being ignored due to e.stopPropogation(). This PR conditionally applies e.stopPropogation() unless the clicked element is not an <a/> element.

vercel[bot] commented 6 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-headlessui-kf6d ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2024 9:04am
stepanorda commented 5 months ago

Is there any reason why it has stopPropogation in the first place? Anyway, this workaround is greatly appreciated and would solve #162

JorensM commented 5 months ago

Is there any reason why it has stopPropogation in the first place? Anyway, this workaround is greatly appreciated and would solve #162

Not sure why it's there honestly, but I guess better to leave it in case it is actually needed for some reason.

Loizzus commented 3 months ago

I have created a new fork for us to share so we can fix these issues: https://github.com/PyongyangOpenSource/svelte-headlessui