question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Link] disabled prop & interaction behaviour

See original GitHub issue

Bug report

Describe the bug

The Link component has default visuals for _disabled. However, the typings do not reflect that and interactions are not actually prevented.

Expected behavior

I’d expect passing disabled to Link to prevent interactions and TypeScript not having issues with that.

  • add disabled?: boolean to LinkProps
  • add documentation for it via JSDoc
  • adjust the props in the docs
  • consider adding an example to the Link docs too
  • all interactions (click, touch) have event.preventDefault() if disabled, otherwise execute props.onClick if present.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
jsefianicommented, Oct 20, 2020

@segunadebayo Thank you for your feedback. I would like to add the following:

  • The Link component becomes indeed non-interactive under the hood if you omit the href attribute, but what about the styling? The Link component still gives me (wrong) feedback (hover state) when no href is provided. Shouldn’t we apply a disabled styling when there’s no href?
3reactions
segunadebayocommented, Oct 20, 2020

Hey guys,

Removing the isDisabled from the link component was intentional. Links are not buttons and shouldn’t have disabled in them. We want to be careful not to invent anti-patterns.

The way to make a link non-interactive is to omit the href attribute.

Permit me to close this as well as the PR.

Thanks guys 💖

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Disable Links | CSS-Tricks
There is a problem though: there is no real way to disable an <a> link (with a valid href attribute) in HTML. Not...
Read more >
How to Disable a Link using Only CSS
Answer: Use the CSS pointer-events Property. You can simply use the CSS pointer-events property to disable a link. The none value of this...
Read more >
How to disable a link using only CSS - Stack Overflow
I have a class called current-page and want links with this class to be disabled so that no action occurs when they are...
Read more >
ARIA: link role - Accessibility - MDN Web Docs
The link role is used to identify an element that creates a hyperlink to a resource that is in the application or external....
Read more >
Links - Material UI - MUI
The Link component allows you to easily customize anchor elements with your theme colors ... The underline prop can be used to set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found