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

[Chip] Control clickable property #13056

Merged
merged 2 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
eps1lon marked this conversation as resolved.
Show resolved Hide resolved
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