Fix JS errors when closing the "Add File" dialog.
Review Request #2039 — Created Nov. 15, 2020 and updated — Latest diff uploaded
DialogView subclasses (such as "Add File") could sometimes cause JS errors when they were closing. The issue here was a race between multiple event handlers. Inside the `modalBox` implementation (which is all our own jQuery-UI based code), a generic handler for clicks in the button area would cause the modal box to self-destruct. This could then conflict with the higher-level DialogView code which would additionally try to call destroy. In previous versions of jQuery-UI this didn't matter, but the version we're using now will error out when calling methods on elements which are not widgets. This change adds a check to make sure we don't try to destroy the modalBox widget after it's already self-destructed. Testing Done: - Manually tested the "Add File" dialog. - Ran js-tests without any modalBox-related errors. Reviewed at https://reviews.reviewboard.org/r/11254/