Merge pull request #1276 from johannpinson/patch-content-manager

Improve <Ico> component for handle click if specified
This commit is contained in:
Jim LAURIE 2018-05-31 14:27:50 +02:00 committed by GitHub
commit 033127105d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -16,15 +16,20 @@ function Ico(props) {
}
const handleClick = (e, onClick) => {
e.preventDefault();
e.stopPropagation();
onClick(e);
if (onClick) {
e.preventDefault();
e.stopPropagation();
onClick(e);
}
};
Ico.propTypes = {
icoType: PropTypes.string,
id: PropTypes.string,
onClick: PropTypes.func,
onClick: PropTypes.oneOfType([
PropTypes.func,
PropTypes.bool,
]),
};
Ico.defaultProps = {

View File

@ -82,7 +82,7 @@ class TableRow extends React.Component {
cells.push(
<td key='action' className={styles.actions}>
<IcoContainer icons={[{ icoType: 'pencil' }, { id: this.props.record.id, icoType: 'trash', onClick: this.props.onDelete }]} />
<IcoContainer icons={[{ icoType: 'pencil', onClick: false }, { id: this.props.record.id, icoType: 'trash', onClick: this.props.onDelete }]} />
</td>
);