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

Joy UI: Disabled Link IconButton appearance appears to still be enabled #43245

Open
BSoDium opened this issue Aug 9, 2024 · 7 comments
Open
Assignees
Labels
component: icon button This is the name of the generic UI component, not the React module! on hold There is a blocker, we need to wait package: joy-ui Specific to @mui/joy

Comments

@BSoDium
Copy link

BSoDium commented Aug 9, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/s/peaceful-estrela-dr8zfz

Steps:

  1. Create a Joy UI IconButton
  2. Set its component prop to either "a" or Link from react-router-dom
  3. Set its disabled prop to true
  4. The button is still clickable and visually appears to be enabled because it is

Current behavior

The button appears to still be enabled even though it shouldn't be.

Expected behavior

The button should be disabled (no pointer-events, less contrast with the background, etc...)

Context

I am simply trying to have a link button be disabled.

My guess: in the DOM, the disabled prop cannot be applied to the a element, which messes up the styles since the selector is literally:

.css-randomId-JoyIconButton-root:disabled {
  // rules
}

Your environment

Tested on Chrome version 127.0.6533.89 (Official Build) (arm64)

npx @mui/envinfo
  System:
    OS: macOS 14.6
  Binaries:
    Node: 22.4.1 - /opt/homebrew/bin/node
    npm: 10.8.2 - /opt/homebrew/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 127.0.6533.100
    Edge: Not Found
    Safari: 17.6
  npmPackages:
    @emotion/react: ^11.11.4 => 11.13.0 
    @emotion/styled: ^11.11.5 => 11.13.0 
    @mui/base:  5.0.0-beta.42 
    @mui/core-downloads-tracker:  6.0.0-dev.240424162023-9968b4889d 
    @mui/joy: ^5.0.0-beta.48 => 5.0.0-dev.240424162023-9968b4889d 
    @mui/private-theming:  6.0.0-dev.20240529-082515-213b5e33ab 
    @mui/styled-engine:  6.0.0-dev.20240529-082515-213b5e33ab 
    @mui/system:  6.0.0-dev.240424162023-9968b4889d 
    @mui/types:  7.2.15 
    @mui/utils:  6.0.0-dev.20240529-082515-213b5e33ab 
    @types/react: ^18.3.3 => 18.3.3 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.5.4 => 5.5.4

Search keywords: IconButton, disabled, Link, react-router-dom, enabled

@BSoDium BSoDium added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 9, 2024
@KumarNitin19
Copy link
Contributor

Yes @BSoDium , there is no disable attribute on a tag. Disabled attribute is only available for few elements (Button, Input, Textarea, Select, Option, ...etc). So you have to handle it using styles.

@BSoDium
Copy link
Author

BSoDium commented Aug 9, 2024

I totally agree with you on the fact that an a element cannot have a disabled state, but if you look at the example from the documentation for link buttons, the normal Button (as opposed to IconButton) does handle that edge case (it can become disabled by setting the disabled prop to true).

Plus, it is a bit misleading to leave the disabled prop available to the user if it is not intended to be used in this specific case, isn't it?

If you are not planning on handling it any time soon, what clean solution would you recommend to palliate to this?

@KumarNitin19
Copy link
Contributor

@BSoDium Yes it's a bug, I will try to fix it and raise a PR for the same. Also if it's urgent for you then try to add some style on the button to disable it. Something like pointer-event:none and color to be grey.

@KumarNitin19
Copy link
Contributor

Screenshot 2024-08-09 at 11 37 00 PM
You can try this as well, but not a solution.

@BSoDium
Copy link
Author

BSoDium commented Aug 9, 2024

I'll experiment with this, greatly appreciate the reactivity, thank you for the help!

@zannager zannager added component: icon button This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy labels Aug 12, 2024
@siriwatknp
Copy link
Member

Thanks for reporting the issue! Joy UI development is temporarily on hold as the maintainers focus on the next two major releases of Material UI

@siriwatknp siriwatknp added on hold There is a blocker, we need to wait and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 21, 2024
@BSoDium
Copy link
Author

BSoDium commented Aug 21, 2024

Are you guys still reviewing and accepting PRs? Or is everything fully on hold?

ony3000 added a commit to ony3000/tailwind-joy that referenced this issue Oct 6, 2024
This breaks the visual equivalence with the current Joy UI icon button component, but allows the `disabled` property to be used in the same way as the button component.

Related issue: mui/material-ui#43245
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: icon button This is the name of the generic UI component, not the React module! on hold There is a blocker, we need to wait package: joy-ui Specific to @mui/joy
Projects
None yet
Development

No branches or pull requests

4 participants