diff --git a/packages/ra-ui-materialui/src/button/BulkDeleteButton.js b/packages/ra-ui-materialui/src/button/BulkDeleteButton.js index b29309bf04f..64243eab030 100644 --- a/packages/ra-ui-materialui/src/button/BulkDeleteButton.js +++ b/packages/ra-ui-materialui/src/button/BulkDeleteButton.js @@ -62,16 +62,21 @@ class BulkDeleteButton extends Component { selectedIds, startUndoable, undoable, + onClick, } = this.props; if (undoable) { startUndoable(crudDeleteMany(resource, selectedIds, basePath)); } else { dispatchCrudDeleteMany(resource, selectedIds, basePath); } + + if (typeof onClick === 'function') { + onClick(); + } }; render() { - const { classes, label, icon, ...rest } = this.props; + const { classes, label, icon, onClick, ...rest } = this.props; return ( diff --git a/packages/ra-ui-materialui/src/button/ExportButton.js b/packages/ra-ui-materialui/src/button/ExportButton.js index bb2f1b325b1..dfe0520ff08 100644 --- a/packages/ra-ui-materialui/src/button/ExportButton.js +++ b/packages/ra-ui-materialui/src/button/ExportButton.js @@ -118,6 +118,7 @@ class ExportButton extends Component { maxResults, sort, resource, + onClick, } = this.props; dispatch( crudGetAll( @@ -135,6 +136,10 @@ class ExportButton extends Component { : downloadCSV(convertToCSV(data), resource) ) ); + + if (typeof onClick === 'function') { + onClick(); + } }; render() { diff --git a/packages/ra-ui-materialui/src/button/RefreshButton.js b/packages/ra-ui-materialui/src/button/RefreshButton.js index 35bd98e8b99..f3cd62f5d26 100644 --- a/packages/ra-ui-materialui/src/button/RefreshButton.js +++ b/packages/ra-ui-materialui/src/button/RefreshButton.js @@ -19,8 +19,13 @@ class RefreshButton extends Component { }; handleClick = event => { + const { refreshView, onClick } = this.props; event.preventDefault(); - this.props.refreshView(); + refreshView(); + + if (typeof onClick === 'function') { + onClick(); + } }; render() { diff --git a/packages/ra-ui-materialui/src/button/RefreshIconButton.js b/packages/ra-ui-materialui/src/button/RefreshIconButton.js index 8c7e54ca959..542008e5626 100644 --- a/packages/ra-ui-materialui/src/button/RefreshIconButton.js +++ b/packages/ra-ui-materialui/src/button/RefreshIconButton.js @@ -22,8 +22,13 @@ class RefreshButton extends Component { }; handleClick = event => { + const { refreshView, onClick } = this.props; event.preventDefault(); - this.props.refreshView(); + refreshView(); + + if (typeof onClick === 'function') { + onClick(); + } }; render() { diff --git a/packages/ra-ui-materialui/src/button/SaveButton.js b/packages/ra-ui-materialui/src/button/SaveButton.js index 638063f0099..8f03113100b 100644 --- a/packages/ra-ui-materialui/src/button/SaveButton.js +++ b/packages/ra-ui-materialui/src/button/SaveButton.js @@ -69,6 +69,7 @@ export class SaveButton extends Component { redirect, saving, showNotification, + onClick, } = this.props; if (saving) { @@ -84,6 +85,10 @@ export class SaveButton extends Component { } handleSubmitWithRedirect(redirect)(); } + + if (typeof onClick === 'function') { + onClick(); + } }; render() { @@ -99,6 +104,7 @@ export class SaveButton extends Component { translate, variant = 'raised', icon, + onClick, ...rest } = this.props;