Skip to content

Commit

Permalink
support onCancel callback prop (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshwery authored and jeroenransijn committed Jul 27, 2018
1 parent fb32b24 commit 9000d62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/corner-dialog/src/CornerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export default class CornerDialog extends PureComponent {
this.props.onCloseComplete()
}

handleCancel = () => {
this.props.onCancel(this.handleClose)
}

handleClose = () => {
this.setState({ exiting: true })
}
Expand Down Expand Up @@ -257,7 +261,7 @@ export default class CornerDialog extends PureComponent {
{confirmLabel}
</Button>
{hasCancel && (
<Button onClick={this.handleClose}>{cancelLabel}</Button>
<Button onClick={this.handleCancel}>{cancelLabel}</Button>
)}
</Pane>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/dialog/src/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class Dialog extends React.Component {
hasCancel,
onCloseComplete,
onOpenComplete,
onCancel,
onConfirm,
confirmLabel,
isConfirmLoading,
Expand Down Expand Up @@ -276,7 +277,7 @@ class Dialog extends React.Component {
<Pane padding={16} float="right">
{/* Cancel should be first to make sure focus gets on it first. */}
{hasCancel && (
<Button tabIndex={0} onClick={close}>
<Button tabIndex={0} onClick={() => onCancel(close)}>
{cancelLabel}
</Button>
)}
Expand Down

0 comments on commit 9000d62

Please sign in to comment.