Fix for #9111

I have added a unit test for #9111 and updated the modal.js to pass.

Let me know if there is anything else you need to merge this.