Skip to content

Commit 5181a52

Browse files
committed
fix: call the onClose callback
Signed-off-by: Mike Murray <hellomikemurray@gmail.com>
1 parent faa51c7 commit 5181a52

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

package/src/components/ConfirmDialog/helpers/useConfirmDialog.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import ConfirmDialogBase from "./ConfirmDialogBase";
55
* @summary React hook for creating detached confirm dialogs with ease
66
* @param {Object} props Props to configure a confirm dialog
77
* @param {String} props.cancelActionText Cancel button text
8-
* @param {Function} props.children Render prop `{({ openDialog }) => ()}`
98
* @param {Boolean} props.closeOnConfirm Close dialog on confirmation. Default `true`
109
* @param {String} props.confirmActionText Text for confirm button
1110
* @param {ReactElement} props.content Child elements of the dialog. Use if this for rendering a custom components in the dialog.
12-
* @param {Boolean} props.isOpen Dialog open/close state
1311
* @param {String|React.Element} props.message Message body. May be a String or a React component. Use if your message is mostly text.
1412
* @param {Function} props.onClose Close callback
1513
* @param {Function} props.onConfirm Confirmation callback
@@ -18,13 +16,17 @@ import ConfirmDialogBase from "./ConfirmDialogBase";
1816
*/
1917
export default function useConfirmDialog({
2018
closeOnConfirm = true,
21-
onConfirm = () => {},
19+
onClose = () => { },
20+
onConfirm = () => { },
2221
...props
2322
}) {
2423
const [isOpen, setOpen] = useState(false);
2524

2625
const openDialog = () => setOpen(true);
27-
const closeDialog = () => setOpen(false);
26+
const closeDialog = () => {
27+
setOpen(false);
28+
onClose();
29+
};
2830
const handleConfirm = () => {
2931
onConfirm();
3032

0 commit comments

Comments
 (0)