primevue icon indicating copy to clipboard operation
primevue copied to clipboard

DynamicDialog: Improved onClose Function

Open jjackevans opened this issue 2 years ago • 0 comments

Describe the feature you would like to see added

The DynamicDialog has an onClose event which is only invoked on the close event.

If one wanted to add restrictions to the close event (like using a ConfirmDialog to verify that the user wants to delete unsaved data), they are required to implement their own close button, in which case the user may still override this check with the button in the header.

I propose having the onClose return a boolean value whether to continue the close event.

Is your feature request related to a problem?

No control over dialogs being closed.

Describe the solution you'd like

  dialog.open(x.component, {
    props: {
      header: x.header,
      modal: true,
      class: x.class,
    },
   onClose: (opts) => {
       confirm.require({
            message: 'Are you sure you want to close - you have unsaved data?',
            header: 'Confirmation',
            reject: () =>  return false,
            accept: () => return true
          })
   }
})

Describe alternatives you have considered

It is possible to load the same dialog when the user chooses to not destroy the dialog. This is not an optimal solution for clear reasons.

Additional context

No response

jjackevans avatar Sep 04 '22 08:09 jjackevans