Quantcast
Viewing all articles
Browse latest Browse all 294796

Ajax replace does not refocus element if inside a dialog

Problem/Motivation

Drupal.Ajax.success attempts to set focus to the element that triggered the ajax request.

You can stop by adding the attribute data-disable-refocus to the element if another InvokeCommand is returned that sets focus.

This functionality is not actually tested anywhere and it does not work if the element is inside a dialog.
In #2995689: Allow reordering blocks without a pointer device it would be great if this worked because we are using an ajax element in dialog.

Proposed resolution

In the AJAX success handler, after the $(target).trigger('focus'); check to see if target is in a dialog.

If it is in a dialog AND that dialog does not have a dedicated focus listener (we don't want to override a deliberately added focus listener), add a temporary focus listener to the dialog for when it receives focus due to autofocus. The focus listener callback will reroute focus back to target where it was intended to go.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 294796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>