Close Modal after record update

Hi,

I think this is not supposed to work as before, the structure of the modal has changed a bit (you can see there is kind of new header at the top of the modal).

There are other ways to do this, for example by forcing the click of the X button.

Though be aware that the selectors are not stable (so it may change again and again).

Here is a code example to be inserted in the parent page, custom code in the header:
The use case is updating a list-details inside the modal => it automatically closes the modal and refreshes the linked list block in the parent page after half a second.

<script>
window.addEventListener('block-loaded-list-details1', () => { 
  window.addEventListener('update-record-success-list-details1', () => {  
    setTimeout(() => {
      const dialogButton = document.querySelector('div[role="dialog"] button');
      if (dialogButton) {
        dialogButton.click();
      }
      window.dispatchEvent(new CustomEvent('reload-block-list1'));
    }, 500); 
  });
});
</script>

The global selector for the button closing the modal is div[role="dialog"] button.
But as I mentioned, it isn’t supposed to be stable and as a result it can change next month or next week I don’t know. So this might be something to put on hold for now.

1 Like