Skip to content

feat: add disabled attribute handling to link #2101

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

D4ve-R
Copy link
Contributor

@D4ve-R D4ve-R commented Nov 22, 2024

This PR adds handling of the disabled attribute to links.

Problem:

Currently clicking on Links where the disabled attribute is set, triggers a request.

<!-- unexpected request on click -->
<Link href="#" disabled>Disabled</Link>

Solution:

Add a disabled prop to the Link Component and stop click & prefetch events, when attribute exists or is set to true

Notes:

The changes are currently only implemented in @interia/vue.
If accepted, I will implement it in @interia/react & @interia/svelte too.

@D4ve-R
Copy link
Contributor Author

D4ve-R commented Nov 22, 2024

fixes #1620

<Link :disabled="disabled">
<!-- instead of -->
<Link :as="disabled ? 'button' : 'a'" :disabled="disabled">

@pascalbaljet
Copy link
Contributor

fixes #1620

<Link :disabled="disabled">
<!-- instead of -->
<Link :as="disabled ? 'button' : 'a'" :disabled="disabled">

Thanks for this! I think it's a good addition even though the a tag does not natively support disabled. But since it also supports other non-native features like prefetching in v2, I think it's no problem.

Could you please implement it in the other packages as well? Thanks!

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

Successfully merging this pull request may close these issues.

2 participants