Intercepting removal of a dizmo

This is an example how you can intercept the (manually triggered) closing of a dizmo by creating a custom dizmo menu. This custom menu entry will allow us to intercept the closing and execute some logic.

In your package.json, disable the “Remove dizmo” menu entry so a user may not close the dizmo.

"dizmo": {
    "settings": {
      "attributes": {
        "settings/usercontrols/allowremove": false
      },
   }
}

Add your own menu entry which can be intercepted. First, add an appropriate icon into e.g. 'assets/Close_Dizmo.svg'
In your JavaScript code, create the custom menu entry:

const closeIcon = './assets/Close_Dizmo.svg'
const closeTitle = 'Remove dizmo'
dizmo.addMenuItem(closeIcon, closeTitle, handleClose)

function handleClose () {
    // Show a modal, e.g.  and upon user confimation either reject this transaction or close the dizmo:
    // var confirmed = getUserConfirmationUsingModal()
    if(confirmed) {
        dizmo.close()    
    } else {
        // Close modal
    }
}