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

Link: Event immer 'prevented' wenn click handler gesetzt #6329

Open
deleonio opened this issue Apr 18, 2024 · 0 comments
Open

Link: Event immer 'prevented' wenn click handler gesetzt #6329

deleonio opened this issue Apr 18, 2024 · 0 comments
Labels
v3 Here are issues that need to be resolved for version 3.

Comments

@deleonio
Copy link
Contributor

deleonio commented Apr 18, 2024

Sobald bei kol-link der onClick Event-Handler gesetzt ist, werden für alle Click-Events preventDefault ausgeführt. Die native Navigation wird also verhindert.

Das passt für viele Fälle, in denen die Aktion komplett überschrieben werden soll, kann aber problematisch sein, wenn zur eigentlichen Navigation eine Aktion nur zusätzlich ausgeführt werden soll.

Relevante Code-Stelle: https://github.com/public-ui/kolibri/blob/develop/packages/components/src/components/link/component.tsx#L45

Aktueller Workaround: Die Navigation muss in JavaScript händisch ausgeführt werden. Hierbei werden ggf. nicht alle Spezialfälle beachtet wie z.B. ctrl+Click oder Mausrad-Click, die Links in neuen Tabs öffnen sollten.
Ein Beispiel für ein solches Workaround haben wir selber in der React Sample App umgesetzt: https://github.com/public-ui/kolibri/blob/develop/packages/samples/react/src/components/Sidebar.tsx#L41

Lösungsansatz: Das preventDefault komplett streichen. Die Entwickler:in ist dann selber dafür verantwortlich, es bei Bedarf auszuführen. Das Verhalten wäre analog zu regulärem HTML/JS. Leider stellt dies einen Breaking Change dar.

@deleonio deleonio added the v3 Here are issues that need to be resolved for version 3. label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 Here are issues that need to be resolved for version 3.
Projects
Status: 📄 Ready
Development

No branches or pull requests

1 participant