GA-MO / react-confirm-alert

react component confirm dialog.
https://ga-mo.github.io/react-confirm-alert/demo/
MIT License
272 stars 105 forks source link

Using with Checkbox #43

Closed sloyer closed 4 years ago

sloyer commented 4 years ago

Great Package! We love the use with buttons but we wanna use this for trying to confirm checkboxes. Unfortunately, we are having an issue where no matter what we do when we click cancel, the checkbox still checks.

We can prevent it initially but can't get it after.

We are using Informed for our Forms

I have attached a sandbox https://codesandbox.io/s/hardcore-sara-j34x8?fontsize=14&hidenavigation=1&theme=dark

`

 const Bear = () => {

confirmAlert({
  title: 'Confirm to submit',
  message: 'Are you sure to do this.',
  willUnmount: () => {

  },
  buttons: [
    {
      label: 'Yes',
      onClick: (e) => {
        // console.log('True');
        // return true;
      },
    },
    {
      label: 'No',
      onClick: (e) => {
        return false;
        console.log('false');
      },
    },
  ],
});
};`
      <label className="saAdminCheckBoxLabel">
        <Checkbox
          onClick={(e) => {
            e.preventDefault();
            Bear();
          }}
          field="arecNeutral"
        />
        <span>Neutral USE THIS ONE</span>
      </label>