May be worth considering putting the modal close on a trigger event, too. If the user gets an error (server crashes or their connection fails) then the modal disappears and there's no indication it's not worked. In one of my projects where I'm doing similar I've made mine return 3 triggers for refreshing content, closing modal and displaying a confirmation toast. Then I've got an
onclick
event on the button in the modal to disable it and then event handlers for HTMX errors to display a toast with a generic failure message and re-enable the button for the user to try again.