tv-modal icon indicating copy to clipboard operation
tv-modal copied to clipboard

Hook into model destroy

Open pktharindu opened this issue 3 years ago • 2 comments

Thank you for this cool package!

I'm trying to show/hide a loading state when toggling a model.

confirmDelete() {
  this.loading = true
  this.$modal.show({
    type: 'danger',
    title: 'Are you sure?',
    body:
      'Are you sure you want to remove this item?',
    primary: {
      label: 'Delete',
      theme: 'red',
      action: () => this.deleteItem(),
    },
    secondary: {
      label: 'Cancel',
      theme: 'white',
      action: () => (this.loading = false),
    },
  })
},

Currently, it turns off the loading on Cancel (secondary) button. I want to be able to do the same when the model is closed, which happens on an outside click.

Also, it would be nice to have the models close on Esc key down too.

pktharindu avatar Mar 21 '21 07:03 pktharindu

The PR here https://github.com/acidjazz/tv-modal/pull/5 once merged will allow for this in 2 different ways. You can provide backdropDismiss:false to prevent closing the modal without tapping an action or by the destroyed parameter which is called if present after the modal is closed.

jerodfritz avatar Mar 24 '21 22:03 jerodfritz

@centogram Can you please separate the destruction options into a separate PR than the inputs? I can approve that much easier

acidjazz avatar Mar 25 '21 23:03 acidjazz