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

bug: UButton to prop doesn't follow the disabled state #473

Closed
sandros94 opened this issue Jul 31, 2023 · 2 comments
Closed

bug: UButton to prop doesn't follow the disabled state #473

sandros94 opened this issue Jul 31, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@sandros94
Copy link
Collaborator

Version

@nuxthq/ui: v2.2.0 & v2.6.0
nuxt: v3.5.0 & v3.6.5

Reproduction Link

Stackblitz repro

Steps to reproduce

<template>
  <div>
    <UButton label="Active with to" to="/test" />
    <UButton label="Disabled with to" disabled to="/test" />
    <UButton label="Disabled" disabled />
  </div>
</template>

What is Expected?

The disabled button that has a to prop should be unclickable.

What is actually happening?

The disabled button with a to prop not only is clickable with the correct link, but it is visibly active regardless of the disabled state.

@sandros94 sandros94 added the bug Something isn't working label Jul 31, 2023
Copy link
Member

Indeed, when using the UButton with a :to prop it creates an html <a>.

I can make a fix to remove the href when its disabled, but the visual style of the button won't be reflected as the disabled attribute doesn't exist on an <a>.

Copy link
Member

With this commit, when setting disabled on a <UButton> / <ULink> (used underneath by the button), the <a> HTML element will have its href removed and the role="link" aria-disabled="true" attributes added.

This will make the link semantically valid. However, the styling will not be applied as Tailwind CSS disabled variant can't be used for this case.

Followed recommendations from this article: https://www.scottohara.me/blog/2021/05/28/disabled-links.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants