Trigger Modal Close button

1.9k Views Asked by At

I would like some assistance executing onHide event function which would setShow state to false when Close Button inside the Modal component is clicked.

X next to Payment Transaction Notification works but Close doesn't

Demo sandbox found here: Sandbox

I've temporarily bypassed submitHandler for debugging the modal only, line 71 will trigger the modal in a normal scenario

Do note Close is meant to window.close()

1

There are 1 best solutions below

0
Zunayed Shahriar On BEST ANSWER

First, you have to add a new callback (e.g: buttonClose) for your modal's Close button.

<Button
    variant="secondary"
    {...props}
    onClick={() => props.buttonClose()}
    className="text-center"
>
Close
</Button>

And invoke it from your Step Component.

<SuccessModal
    ref={props.superModalElement}
    show={show}
    onHide={handleClose}
    buttonClose={handleClose}
/>

Working demo at CodeSandbox.