Skip to content

Commit

Permalink
fix: call the onClose callback
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Murray <[email protected]>
  • Loading branch information
mikemurray committed Feb 21, 2020
1 parent faa51c7 commit 5181a52
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions package/src/components/ConfirmDialog/helpers/useConfirmDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import ConfirmDialogBase from "./ConfirmDialogBase";
* @summary React hook for creating detached confirm dialogs with ease
* @param {Object} props Props to configure a confirm dialog
* @param {String} props.cancelActionText Cancel button text
* @param {Function} props.children Render prop `{({ openDialog }) => ()}`
* @param {Boolean} props.closeOnConfirm Close dialog on confirmation. Default `true`
* @param {String} props.confirmActionText Text for confirm button
* @param {ReactElement} props.content Child elements of the dialog. Use if this for rendering a custom components in the dialog.
* @param {Boolean} props.isOpen Dialog open/close state
* @param {String|React.Element} props.message Message body. May be a String or a React component. Use if your message is mostly text.
* @param {Function} props.onClose Close callback
* @param {Function} props.onConfirm Confirmation callback
Expand All @@ -18,13 +16,17 @@ import ConfirmDialogBase from "./ConfirmDialogBase";
*/
export default function useConfirmDialog({
closeOnConfirm = true,
onConfirm = () => {},
onClose = () => { },
onConfirm = () => { },
...props
}) {
const [isOpen, setOpen] = useState(false);

const openDialog = () => setOpen(true);
const closeDialog = () => setOpen(false);
const closeDialog = () => {
setOpen(false);
onClose();
};
const handleConfirm = () => {
onConfirm();

Expand Down

0 comments on commit 5181a52

Please sign in to comment.