From b5577eed25a149a00b26c7785f8ad3d35b41e961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20GAULIN?= Date: Sat, 8 Aug 2015 21:59:19 +0200 Subject: [PATCH] Disable SweetAlert forced focus when a Bootstrap modal is already open (which was causing infinite loop). Bootstrap is enforcing focus on it's modal box, sweet alert too. Focus on sweet alert buttons is not really important, keyboard actions are still available. --- modules/backend/assets/vendor/sweet-alert/sweet-alert.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/backend/assets/vendor/sweet-alert/sweet-alert.js b/modules/backend/assets/vendor/sweet-alert/sweet-alert.js index 9ca8e0f97..7174ac61d 100644 --- a/modules/backend/assets/vendor/sweet-alert/sweet-alert.js +++ b/modules/backend/assets/vendor/sweet-alert/sweet-alert.js @@ -386,7 +386,13 @@ function handleOnBlur(e) { var $targetElement = e.target || e.srcElement, $focusElement = e.relatedTarget, - modalIsVisible = hasClass(modal, 'visible'); + modalIsVisible = hasClass(modal, 'visible'), + bootstrapModalIsVisible = document.querySelector('.control-popup.modal') || false; + + if(bootstrapModalIsVisible) { + // Bootstrap will enforce focus on the existing model, so don't do anything here to prevent infinite loop + return; + } if (modalIsVisible) { var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.