diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php
index 243a9af..23524d49 100644
--- a/core/lib/Drupal/Core/Render/Element/RenderElement.php
+++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php
@@ -264,11 +264,6 @@ public static function preRenderAjaxForm($element) {
       return $element;
     }
 
-    // Add a data attribute to disable automatic refocus after ajax call.
-    if (!empty($element['#ajax']['disable-refocus'])) {
-      $element['#attributes']['data-disable-refocus'] = "true";
-    }
-
     // Add a reasonable default event handler if none was specified.
     if (isset($element['#ajax']) && !isset($element['#ajax']['event'])) {
       switch ($element['#type']) {
@@ -320,6 +315,13 @@ public static function preRenderAjaxForm($element) {
       }
     }
 
+    // Disable automatic refocus after ajax call by adding a data attribute if
+    // the disable-refocus flag has been set or the ajax event is 'blur' to
+    // avoid an infinite focus loop.
+    if (!empty($element['#ajax']['disable-refocus']) || (!empty($element['#ajax']['event']) && $element['#ajax']['event'] == 'blur')) {
+      $element['#attributes']['data-disable-refocus'] = "true";
+    }
+
     // Attach JavaScript settings to the element.
     if (isset($element['#ajax']['event'])) {
       $element['#attached']['library'][] = 'core/jquery.form';
