Skip to content

Commit

Permalink
Merge pull request #3006 from akshah123/clone_button_propogation
Browse files Browse the repository at this point in the history
Fix CloneButton double redirection when used in Datagrid with rowClick
  • Loading branch information
fzaninotto authored Mar 14, 2019
2 parents 0999617 + 83eb92b commit 0a8f0f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/ra-ui-materialui/src/button/CloneButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { Link } from 'react-router-dom';

import Button from './Button';

// useful to prevent click bubbling in a datagrid with rowClick
const stopPropagation = e => e.stopPropagation();

const omitId = ({ id, ...rest }) => rest;

const sanitizeRestProps = ({
Expand Down Expand Up @@ -33,6 +36,7 @@ export const CloneButton = ({
state: { record: omitId(record) },
}}
label={label}
onClick={stopPropagation}
{...sanitizeRestProps(rest)}
>
{icon}
Expand Down

0 comments on commit 0a8f0f5

Please sign in to comment.