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

Disabled prop of Link component doesn't work #1620

Closed
Ferks-FK opened this issue Jul 25, 2023 · 3 comments
Closed

Disabled prop of Link component doesn't work #1620

Ferks-FK opened this issue Jul 25, 2023 · 3 comments
Labels
react Related to the react adapter

Comments

@Ferks-FK
Copy link

Version:

  • @inertiajs/react version: ^1.0.9

Describe the problem:

When trying to provide the disabled attribute for the Link component of inertia, it is completely ignored.
I believe the link should not work if disabled is true.

Steps to reproduce:

Just import the Link from '@inertiajs/react', and try setting a disabled prop.
See the link still working normally when it should be blocked.

@Ferks-FK Ferks-FK added the react Related to the react adapter label Jul 25, 2023
Ferks-FK added a commit to Ferks-FK/SourceAdmin that referenced this issue Jul 25, 2023
…friendly.

The next and previous button are not disabled when reaching the last or first page, this is an expected bug, until inertia solves it. (inertiajs/inertia#1620)
@reinink
Copy link
Member

reinink commented Jul 28, 2023

Hey! So under the hood Inertia just uses regular <a> tags for links, which don't support disabled. You can make the Inertia <Link> a button using the as prop, in which case you can use disabled, since that's supported by the native <button> element:

<Link as="button" href="/somewhere">My Link</Link>

Hope that helps!

@reinink reinink closed this as completed Jul 28, 2023
@gareginra
Copy link

Idk about React, but this works in Vue, it's called "renderless component":
<component :is="editMode ? 'div' : Link" :href="sectionLink">

@Zai185
Copy link

Zai185 commented Oct 13, 2024

@gareginra Cool Trick bro, Thanks for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react Related to the react adapter
Projects
None yet
Development

No branches or pull requests

4 participants