summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcboyden2017-01-08 15:08:08 +0100
committerEmil Stjerneman2017-01-08 15:08:08 +0100
commitb24d9271ce74d4180df285ce808e66f7b1f44d1e (patch)
tree7b395f711458eb1353bc4b0ccde3dd124563ab4a
parent31ae929f98681898d5d3df29ff5f7609d7140de9 (diff)
Issue #2811421 by cboyden, dsnopek, anon: Keyboard focus is lost when Linkit modal closes (accessibility issue)7.x-3.x
-rw-r--r--js/linkit.field.js10
-rw-r--r--js/linkit.js8
2 files changed, 18 insertions, 0 deletions
diff --git a/js/linkit.field.js b/js/linkit.field.js
index 903f61d..e6e9b65 100644
--- a/js/linkit.field.js
+++ b/js/linkit.field.js
@@ -146,6 +146,16 @@
getField: function(id) {
return document.getElementById(id);
+ },
+
+ /**
+ * Set browser focus to the button that triggered the modal for better
+ * accessibility.
+ */
+ onModalClose: function() {
+ var instance = Drupal.settings.linkit.currentInstance;
+ $('.linkit-field-' + instance.source).focus();
}
+
});
})(jQuery, 'linkitField');
diff --git a/js/linkit.js b/js/linkit.js
index 7e9664e..dd167e9 100644
--- a/js/linkit.js
+++ b/js/linkit.js
@@ -80,6 +80,14 @@ Drupal.linkit.modalOptions = function() {
*/
Drupal.linkit.modalClose = function (e) {
$('#linkit-modal').dialog('destroy').remove();
+
+ // Run the onModalClose() function.
+ var helper_name = Drupal.settings.linkit.currentInstance.helper,
+ helper = Drupal.linkit.getDialogHelper(helper_name);
+ if (typeof helper.onModalClose === 'function') {
+ helper.onModalClose();
+ }
+
// Make sure the current intstance settings are removed when the modal is
// closed.
Drupal.settings.linkit.currentInstance = {};