primevue icon indicating copy to clipboard operation
primevue copied to clipboard

ConfirmDialog won't the reject event be triggered when closing things?

Open terranc opened this issue 3 years ago • 1 comments

Describe the bug

ConfirmDialog won't the reject event be triggered when closing things? What is the best practice to listen to the close event?

Reproducer

https://codesandbox.io/s/nostalgic-https-31pz16?file=/src/ConfirmDialogDemo.vue

PrimeVue version

3.15

Vue version

3.x

Language

ALL

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

terranc avatar Jul 31 '22 07:07 terranc

Same issue here. I'd appreciate a "Promise variant" of the ConfirmDialog (and ideally the other dialog options as well). I'm used to work with promises. To my understanding using promises is a more modern JavaScript and produces better code than using callbacks.

In principle one can "promisify" the function on its own, e.g.

async function confDialog() {
      return new Promise<boolean>((resolve) => {
        confirm.require({
          message: 'Are you sure you want to proceed?',
          header: 'Confirmation',
          icon: 'pi pi-exclamation-triangle',
          accept: () => resolve(true),
          reject: () => resolve(false),
        })
      })
    }

But if the ConfirmDialog is just closed, there is no way to catch this and call resolve(false). There I fully support this issue!

some-user123 avatar Aug 09 '22 18:08 some-user123

Fixed via #2938

tugcekucukoglu avatar Sep 08 '22 12:09 tugcekucukoglu