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 html attribute is not set on Button if passed in as prop to MenuItem #7816

Closed
3 tasks done
Mikunj opened this issue Jun 30, 2023 · 4 comments
Closed
3 tasks done

Comments

@Mikunj
Copy link

Mikunj commented Jun 30, 2023

Description

If you pass in a Button as an as prop to MenuItem and disable it, it will not render with the disabled html attribute. Everything else works as expected: Button cannot be clicked, menu item cannot be focused

This issue is not present in @chakra-ui/button: "2.0.15"

Examples

<!-- button won't have disabled attribute -->
<MenuItem as={Button} isDisabled>My Disabled Item</MenuItem>

<!-- button has disabled attribute -->
<Button isDisabled>My Disabled Button</Button>

Link to Reproduction

https://codesandbox.io/s/modest-hoover-yfrdt6?file=/src/index.js

Steps to reproduce

No response

Chakra UI Version

2.7.1

Browser

No response

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

@onurhan1337
Copy link

As far as I have tested, MenuItem cannot get the disabled property after giving as={Button} property as you mentioned. In fact, when we give the isDisabled property, onClick does not work, but both the disabled property and disabled button styling do not work. I'm having the same problem.

@Mikunj
Copy link
Author

Mikunj commented Jul 14, 2023

I have investigated this further and found that useMenuItem hook returns disabled as the prop (Code reference) which is then ignored by Button component (Code reference)

Philzen added a commit to Philzen/chakra-ui that referenced this issue Apr 24, 2024
This reverts commit 0f37665.

Fixes chakra-ui#7269, chakra-ui#7816 and chakra-ui#7905 and also enables the only currently known
workaround for 	chakra-ui#7965. Removing the ability to use the disabled-prop
posed a breaking change, which is hereby fixed.
segunadebayo added a commit that referenced this issue May 8, 2024
* Revert "refactor: button disabled prop"

This reverts commit 0f37665.

Fixes #7269, #7816 and #7905 and also enables the only currently known
workaround for 	#7965. Removing the ability to use the disabled-prop
posed a breaking change, which is hereby fixed.

* docs: update

---------

Co-authored-by: Segun Adebayo <joseshegs@gmail.com>
@Philzen
Copy link
Contributor

Philzen commented May 10, 2024

@Mikunj #8462 has been merged, disabled prop on button works again, you can test that out in the LiveCoding-view here: https://chakra-ui-website-ptekgabqh-chakra-ui.vercel.app/docs/components/button/usage

If satisfied, you may close this issue, the fix should be shipping with Chakra 2.8.3.

@Mikunj
Copy link
Author

Mikunj commented May 12, 2024

Awesome 🎉, seems to work as intended now 😃

@Mikunj Mikunj closed this as completed May 12, 2024
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 a pull request may close this issue.

3 participants