Skip to content

Commit

Permalink
Issue-#13052 clickable false prop
Browse files Browse the repository at this point in the history
  • Loading branch information
vilvaathiban-sixt committed Oct 1, 2018
1 parent 0cf866a commit a160fe0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
15 changes: 15 additions & 0 deletions docs/src/pages/demos/chips/Chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ function Chips(props) {
href="#chip"
clickable
/>
<Chip
avatar={<Avatar>MB</Avatar>}
label="Non-Clickable Chip with onClick"
onClick={handleClick}
clickable={false}
className={classes.chip}
/>
<Chip
avatar={<Avatar>MB</Avatar>}
label="Non-Clickable Deletable Chip with onClick"
onClick={handleClick}
onDelete={handleDelete}
clickable={false}
className={classes.chip}
/>
<Chip
avatar={<Avatar>MB</Avatar>}
label="Primary Clickable Chip"
Expand Down
11 changes: 6 additions & 5 deletions packages/material-ui/src/Chip/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ class Chip extends React.Component {
variant,
...other
} = this.props;

const clickableFlag = clickable === false ? false : onClick || clickable;
const className = classNames(
classes.root,
{
[classes[`color${capitalize(color)}`]]: color !== 'default',
[classes.clickable]: onClick || clickable,
[classes.clickable]: clickableFlag,
[classes[`clickableColor${capitalize(color)}`]]:
(onClick || clickable) && color !== 'default',
(clickableFlag) && color !== 'default',
[classes.deletable]: onDelete,
[classes[`deletableColor${capitalize(color)}`]]: onDelete && color !== 'default',
[classes.outlined]: variant === 'outlined',
Expand Down Expand Up @@ -408,7 +408,8 @@ Chip.propTypes = {
className: PropTypes.string,
/**
* If true, the chip will appear clickable, and will raise when pressed,
* even if the onClick property is not defined. This can be used, for example,
* even if the onClick property is not defined. If false, the chip will not be clickable,
* even if onClick peoperty is defined. This can be used, for example,
* along with the component property to indicate an anchor Chip is clickable.
*/
clickable: PropTypes.bool,
Expand Down Expand Up @@ -461,7 +462,7 @@ Chip.propTypes = {
};

Chip.defaultProps = {
clickable: false,
clickable: null,
component: 'div',
color: 'default',
variant: 'default',
Expand Down
2 changes: 1 addition & 1 deletion pages/api/chip.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Chips represent complex entities in small blocks, such as a contact.
| <span class="prop-name">avatar</span> | <span class="prop-type">element |   | Avatar element. |
| <span class="prop-name">children</span> | <span class="prop-type">unsupportedProp |   | This property isn't supported. Use the `component` property if you need to change the children structure. |
| <span class="prop-name">classes</span> | <span class="prop-type">object |   | Override or extend the styles applied to the component. See [CSS API](#css-api) below for more details. |
| <span class="prop-name">clickable</span> | <span class="prop-type">bool | <span class="prop-default">false</span> | If true, the chip will appear clickable, and will raise when pressed, even if the onClick property is not defined. This can be used, for example, along with the component property to indicate an anchor Chip is clickable. |
| <span class="prop-name">clickable</span> | <span class="prop-type">bool | <span class="prop-default">null</span> | If true, the chip will appear clickable, and will raise when pressed, even if the onClick property is not defined. If false, the chip will not be clickable, even if onClick peoperty is defined. This can be used, for example, along with the component property to indicate an anchor Chip is clickable. |
| <span class="prop-name">color</span> | <span class="prop-type">enum:&nbsp;'default'&nbsp;&#124;<br>&nbsp;'primary'&nbsp;&#124;<br>&nbsp;'secondary'<br> | <span class="prop-default">'default'</span> | The color of the component. It supports those theme colors that make sense for this component. |
| <span class="prop-name">component</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;func&nbsp;&#124;<br>&nbsp;object<br> | <span class="prop-default">'div'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
| <span class="prop-name">deleteIcon</span> | <span class="prop-type">element |   | Override the default delete icon element. Shown only if `onDelete` is set. |
Expand Down

0 comments on commit a160fe0

Please sign in to comment.