Skip to content

Commit

Permalink
[Chip] Control clickable property (#13056)
Browse files Browse the repository at this point in the history
* Issue-#13052 clickable false prop

* let's merge
  • Loading branch information
vilvaathibanpb authored and oliviertassinari committed Oct 23, 2018
1 parent 1f9c3cf commit ffe6ee3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/material-ui/src/Chip/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Chip extends React.Component {
avatar: avatarProp,
classes,
className: classNameProp,
clickable,
clickable: clickableProp,
color,
component: Component,
deleteIcon: deleteIconProp,
Expand All @@ -292,13 +292,13 @@ class Chip extends React.Component {
...other
} = this.props;

const clickable = clickableProp !== false && onClick ? true : clickableProp;
const className = classNames(
classes.root,
{
[classes[`color${capitalize(color)}`]]: color !== 'default',
[classes.clickable]: onClick || clickable,
[classes[`clickableColor${capitalize(color)}`]]:
(onClick || clickable) && color !== 'default',
[classes.clickable]: clickable,
[classes[`clickableColor${capitalize(color)}`]]: clickable && color !== 'default',
[classes.deletable]: onDelete,
[classes[`deletableColor${capitalize(color)}`]]: onDelete && color !== 'default',
[classes.outlined]: variant === 'outlined',
Expand Down Expand Up @@ -408,7 +408,9 @@ 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 +463,6 @@ Chip.propTypes = {
};

Chip.defaultProps = {
clickable: false,
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 |   | 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 ffe6ee3

Please sign in to comment.