Currently the library gives errors when removing focusable elements in the dialog.
The tab wrapping stops working if the last focusable element in the dialog is removed.
This can be fixed, while simplifying things, by removing the classes of js-first-focus and js-last-focus and instead finding the first and last focusable elements when the wrapping is handled. The performance difference is nothing to worry about.
I also needed to prevent closing the dialog when clicking a button that removes itself. The click-outside feature was not finding the removed button within the modal, given that it's no longer in the DOM, and thus considering it a click outside the modal.
Here's the modal in question:

The Clear (and Save MIDI File) buttons cause the row to be removed (that contains them).
Currently the library gives errors when removing focusable elements in the dialog.
The tab wrapping stops working if the last focusable element in the dialog is removed.
This can be fixed, while simplifying things, by removing the classes of
js-first-focusandjs-last-focusand instead finding the first and last focusable elements when the wrapping is handled. The performance difference is nothing to worry about.I also needed to prevent closing the dialog when clicking a button that removes itself. The click-outside feature was not finding the removed button within the modal, given that it's no longer in the DOM, and thus considering it a click outside the modal.
Here's the modal in question:

The Clear (and Save MIDI File) buttons cause the row to be removed (that contains them).