FIX: attempts to make autofocus more resilient in modals (PR #10680)

The current situation could cause a transition on the button to end after/during modal has shown and causing the button to get focus again. Browsers would then refuse to switch focus.

This is a kinda convulted solution, but it’s a general purpose solution which doesn’t involve changing anything in plugins/themes or core templates.


This pull request has been mentioned on Discourse Meta. There might be relevant details there: