-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Chip] clickable={false} option still executes onClick method #24611
Comments
@asjustis Interesting, the clickable prop has the following description:
I don't think that we should implement the behavior proposed because |
@oliviertassinari ah, I see, agreed that it would most likely be a breaking change. The name
It seems, this part in documentation might be misleading. Maybe a note in documentation would help to clarify this? diff --git a/packages/material-ui/src/Chip/Chip.d.ts b/packages/material-ui/src/Chip/Chip.d.ts
index cab738ff63..d9a6b2b480 100644
--- a/packages/material-ui/src/Chip/Chip.d.ts
+++ b/packages/material-ui/src/Chip/Chip.d.ts
@@ -89,9 +89,10 @@ export interface ChipTypeMap<P = {}, D extends React.ElementType = 'div'> {
/**
* If `true`, the chip will appear clickable, and will raise when pressed,
* even if the onClick prop is not defined.
- * If false, the chip will not be clickable, even if onClick prop is defined.
+ * If `false`, the chip will not be clickable, even if onClick prop is defined.
* This can be used, for example,
* along with the component prop to indicate an anchor Chip is clickable.
+ * Note: this controls the UI and does not affect the onClick event.
*/
clickable?: boolean;
/** |
This clarification sounds great, do you want to update the docs in |
@oliviertassinari Ah didn't get back in time. Thanks for closing this! |
Hi,
Current Behavior 😯
I am trying to conditionally render my Chip component to be clickable or read-only. When I set
clickable={false}
, it still executesonClick
when pressed.Expected Behavior 🤔
I would naturally expect that both UI and the method execution would be disabled by the
clickable={false}
option.Steps to Reproduce 🕹
I added a quick sandbox example here to reproduce: https://codesandbox.io/s/vigilant-water-2yygy?file=/src/App.js
Steps:
onClick
methodclickable={false}
lineonClick()
methodYour Environment 🌎
Using latest 4.11.3 core version:
The text was updated successfully, but these errors were encountered: