One "quick" and "global" fix could be to neutralize the backdrop click events completely, and just rely on the close button of the modal.
The mouseup outside of modal body I have encountered in other software before, but never in Flarum. Is there an extension I can reproduce that with? This is the related issue in bootstrap jquery which we use twbs/bootstrap13816 but I'd hope the version of bootstrap we currently use has the fix.
As for accidentally leaving a modal with unsubmitted data, Modal.prototype.hide
should have been the perfect place to override that handling. Unfortunately because the backdrop is outside of the Modal component, the method isn't called when clicking the backdrop. Instead ModalState.prototype.close
should be the place to handle it, but it might only have limited information about which modal is currently shown.
There's also the isDismissible
static property of the Modal object, which was previously a method in beta 13 but can no longer exist without component instances.
While it would require a bit of refactoring, I would quite like the backdrop to be part of the Modal component itself, that way all of the modal+backdrop interaction could be handled within a single component without having to rely on even more state objects.
An alternative solution which I've started to use in some of my Mithril apps is to trigger DOM events manually. For example clicking on the backdrop could look for the close button of the modal and trigger a click on it. This works around the difficulties of handling parent/children component communication when all you want to do is extend a clickable area to outside a component.