Screen lock not removed sometimes when ajax response returned. It's because in same time can be send other ajax, which set unblock=false and not runed blockUI().
First simple solution, check if screen lock already showed. For this we should use condition and check onblock variable.

Here my example, which contain other my patches:

(function($) {
  var unblock;
  $(document).ajaxSend(function(event, jqxhr, settings) {
    if (unblock != true) {
      unblock = false;
      var target = settings.url;
      var pages = Drupal.settings.ajax_screen_lock.pages;
      var visibility = Drupal.settings.ajax_screen_lock.visibility;
      var throbber_hide = Drupal.settings.ajax_screen_lock.throbber_hide;
      var disabled = Drupal.settings.ajax_screen_lock.disabled;
      var blockui = function () {
        unblock = true;
        if (throbber_hide) {
          $('.ajax-progress-throbber').hide();
        }

        $.blockUI({
          message: Drupal.settings.ajax_screen_lock.message,
          css: {
            top: ($(window).height() - 400) / 2 + 'px',
            left: ($(window).width() - 400) / 2 + 'px',
            width: '400px'
          },
          timeout: Drupal.settings.ajax_screen_lock.timeout
        });
      }

      // If is not disabled.
      if (!disabled) {
        if (!$.isEmptyObject(pages)) {
          // Handle pages.
          $.each(pages, function (num, page) {
            if (target.length >= page.trim().length) {
              if (target.substr(0, page.trim().length) == page.trim() && visibility == 1) {
                blockui();
              }
              else if (visibility == 0 && target.substr(0, page.trim().length) != page.trim()) {
                blockui();
              }
            }
          });
        }
        else {
          blockui();
        }
      }
    }
  });

  $(document).ajaxStop(function(r, s) {
    if (unblock) {
      $.unblockUI();
    }
  });
}(jQuery));

Comments

samvel’s picture

Also it's not working example, i will update it soon

samvel’s picture

Assigned: samvel » Unassigned
Status: Active » Needs review
StatusFileSize
new3.2 KB

Patch attached.
But pay attention, in this case ajax screen will be unlocked after first ajax responsed. Second Ajax request won't be processed.

eugene.ilyin’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hello Samvel

Sorry, but I can't reproduce this problem.
Can you provide more details?

I tryed to use this PoC in console:

jQuery.ajax({'url': '/system/ajax'});
setTimeout(function() {
  jQuery.ajax({'url': '/system/ajax'});
}, 50);
eugene.ilyin’s picture

I'm closing this issue, but not hesitate to open it again if you'll have troubles.

eugene.ilyin’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.