Skip to content

Commit

Permalink
Issue #6351: Fix jquery.ui focus conflict for CKEditor form elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
indigoxela committed Jan 6, 2024
1 parent 404c61d commit 298b285
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/modules/ckeditor5/ckeditor5.module
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ function ckeditor5_library_info() {
return $libraries;
}

/**
* Implements hook_library_info_alter().
*/
function ckeditor5_library_info_alter(&$libraries, $module) {
if ($module == 'system' && isset($libraries['ui.dialog'])) {
// Override jquery.ui dialog _allowInteraction method to allow interaction
// for editor form elements from within jquery dialogs.
// @see https://bugs.jqueryui.com/ticket/9087/
$path = backdrop_get_path('module', 'ckeditor5') . '/js/ckeditor5-dialog-fix.js';
$libraries['ui.dialog']['js'][$path] = array();
}
}

/**
* Implements hook_theme().
*/
Expand Down
28 changes: 28 additions & 0 deletions core/modules/ckeditor5/js/ckeditor5-dialog-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @file
* Fix conflict with jquery.ui focusin event handling in dialogs.
*/
(function ($) {

'use strict';

/**
* Override the _allowInteraction() extension point.
*
* @see https://api.jqueryui.com/dialog/#method-_allowInteraction
* @see https://bugs.jqueryui.com/ticket/9087/
*/
$.widget('ui.dialog', $.ui.dialog, {
_allowInteraction: function _allowInteraction(event) {
// The CKEditor 5 balloon toolbar is outside the modal container, by
// specifying CKEditor elements as allowed-interaction outside the modal,
// the balloon buttons can be clicked. All editor form elements, like
// buttons in balloon toolbars get the "ck" class.
if ($(event.target).hasClass('ck')) {
return true;
}
return this._super(event);
}
});

})(jQuery);

0 comments on commit 298b285

Please sign in to comment.