Skip to content
Snippets Groups Projects
Verified Commit 66c3914d authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3296098 by catch, finnsky, smustgrave: Removal :tabbable usage in dialog.js

parent 244a7eeb
No related branches found
No related tags found
26 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #149298 passed with warnings
Pipeline: drupal

#149301

    Showing
    with 123 additions and 15 deletions
    ......@@ -76,6 +76,12 @@ public function __construct($selector, string|\Stringable|null $title, $content,
    $title = PlainTextOutput::renderFromHtml($title);
    $dialog_options += ['title' => $title];
    if (isset($dialog_options['dialogClass'])) {
    @trigger_error('Passing $dialog_options[\'dialogClass\'] to OpenDialogCommand::__construct() is deprecated in drupal:10.3.0 and will be removed in drupal:12.0.0. Use $dialog_options[\'classes\'] instead. See https://www.drupal.org/node/3440844', E_USER_DEPRECATED);
    $dialog_options['classes']['ui-dialog'] = $dialog_options['dialogClass'];
    unset($dialog_options['dialogClass']);
    }
    $this->selector = $selector;
    $this->content = $content;
    $this->dialogOptions = $dialog_options;
    ......
    ......@@ -38,6 +38,21 @@ class OpenOffCanvasDialogCommand extends OpenDialogCommand {
    * (optional) The position to render the off-canvas dialog.
    */
    public function __construct(string|\Stringable|null $title, $content, array $dialog_options = [], $settings = NULL, $position = 'side') {
    $dialog_class = FALSE;
    if (isset($dialog_options['classes']['ui-dialog'])) {
    $dialog_class = $dialog_options['classes']['ui-dialog'];
    }
    elseif (isset($dialog_options['dialogClass'])) {
    @trigger_error('Passing $dialog_options[\'dialogClass\'] to OpenOffCanvasDialogCommand::__construct() is deprecated in drupal:10.3.0 and will be removed in drupal:12.0.0. Use $dialog_options[\'classes\'] instead. See https://www.drupal.org/node/3440844', E_USER_DEPRECATED);
    $dialog_class = $dialog_options['dialogClass'];
    unset($dialog_options['dialogClass']);
    }
    if ($dialog_class) {
    $dialog_options['classes']['ui-dialog'] = $dialog_class . ' ' . "ui-dialog-off-canvas ui-dialog-position-$position";
    }
    else {
    $dialog_options['classes']['ui-dialog'] = "ui-dialog-off-canvas ui-dialog-position-$position";
    }
    parent::__construct('#drupal-off-canvas', $title, $content, $dialog_options, $settings);
    $this->dialogOptions['modal'] = FALSE;
    $this->dialogOptions['autoResize'] = FALSE;
    ......@@ -45,9 +60,7 @@ public function __construct(string|\Stringable|null $title, $content, array $dia
    $this->dialogOptions['draggable'] = FALSE;
    $this->dialogOptions['drupalAutoButtons'] = FALSE;
    $this->dialogOptions['drupalOffCanvasPosition'] = $position;
    if (empty($dialog_options['dialogClass'])) {
    $this->dialogOptions['dialogClass'] = "ui-dialog-off-canvas ui-dialog-position-$position";
    }
    // Add CSS class to #drupal-off-canvas element. This enables developers to
    // select previous versions of off-canvas styles by using custom selector:
    // #drupal-off-canvas:not(.drupal-off-canvas-reset).
    ......
    ......@@ -30,6 +30,82 @@
    $buttons.eq(index).addClass(opts.buttonPrimaryClass);
    }
    },
    _createWrapper() {
    this.uiDialog = $('<div>')
    .hide()
    .attr({
    // Setting tabIndex makes the div focusable
    tabIndex: -1,
    role: 'dialog',
    })
    .appendTo(this._appendTo());
    this._addClass(
    this.uiDialog,
    'ui-dialog',
    'ui-widget ui-widget-content ui-front',
    );
    this._on(this.uiDialog, {
    keydown(event) {
    if (
    this.options.closeOnEscape &&
    !event.isDefaultPrevented() &&
    event.keyCode &&
    event.keyCode === $.ui.keyCode.ESCAPE
    ) {
    event.preventDefault();
    this.close(event);
    return;
    }
    // Prevent tabbing out of dialogs
    if (
    event.keyCode !== $.ui.keyCode.TAB ||
    event.isDefaultPrevented()
    ) {
    return;
    }
    const tabbableElements = tabbable(this.uiDialog[0]);
    if (tabbableElements.length) {
    const first = tabbableElements[0];
    const last = tabbableElements[tabbableElements.length - 1];
    if (
    (event.target === last || event.target === this.uiDialog[0]) &&
    !event.shiftKey
    ) {
    this._delay(function () {
    $(first).trigger('focus');
    });
    event.preventDefault();
    } else if (
    (event.target === first || event.target === this.uiDialog[0]) &&
    event.shiftKey
    ) {
    this._delay(function () {
    $(last).trigger('focus');
    });
    event.preventDefault();
    }
    }
    },
    mousedown(event) {
    if (this._moveToTop(event)) {
    this._focusTabbable();
    }
    },
    });
    // We assume that any existing aria-describedby attribute means
    // that the dialog content is marked up properly
    // otherwise we brute force the content as the description
    if (!this.element.find('[aria-describedby]').length) {
    this.uiDialog.attr({
    'aria-describedby': this.element.uniqueId().attr('id'),
    });
    }
    },
    // Override jQuery UI's `_focusTabbable()` so finding tabbable elements uses
    // the core/tabbable library instead of jQuery UI's `:tabbable` selector.
    _focusTabbable() {
    ......
    ......@@ -12,14 +12,12 @@
    * @type {object}
    *
    * @prop {boolean} [autoOpen=true]
    * @prop {string} [dialogClass='']
    * @prop {string} [buttonClass='button']
    * @prop {string} [buttonPrimaryClass='button--primary']
    * @prop {function} close
    */
    drupalSettings.dialog = {
    autoOpen: true,
    dialogClass: '',
    // Drupal-specific extensions: see dialog.jquery-ui.js.
    buttonClass: 'button',
    buttonPrimaryClass: 'button--primary',
    ......
    ......@@ -820,8 +820,9 @@ media_library_mediaLibrary:
    name: Drupal.ckeditor5.openDialog
    invoke: false
    dialogSettings:
    classes:
    ui-dialog: media-library-widget-modal
    height: 75%
    dialogClass: media-library-widget-modal
    drupal:
    label: Media Library
    elements: false
    ......
    ......@@ -137,7 +137,9 @@
    );
    const confirmationDialog = Drupal.dialog(`<div>${message}</div>`, {
    title: Drupal.t('Change text format?'),
    dialogClass: 'editor-change-text-format-modal',
    classes: {
    'ui-dialog': 'editor-change-text-format-modal',
    },
    resizable: false,
    buttons: [
    {
    ......
    ......@@ -89,7 +89,9 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Req
    */
    public static function dialogOptions() {
    return [
    'dialogClass' => 'media-library-widget-modal',
    'classes' => [
    'ui-dialog' => 'media-library-widget-modal',
    ],
    'title' => t('Add or select media'),
    'height' => '75%',
    'width' => '75%',
    ......
    ......@@ -126,7 +126,9 @@ public function linksDisplay() {
    'class' => ['use-ajax'],
    'data-dialog-type' => 'modal',
    'data-dialog-options' => Json::encode([
    'dialogClass' => 'no-close',
    'classes' => [
    'ui-dialog' => 'no-close',
    ],
    ]),
    ],
    '#attached' => [
    ......
    ......@@ -47,6 +47,10 @@ public function testDialog($position) {
    'data' => (string) $dialog_contents,
    'dialogOptions' =>
    [
    'classes' => [
    'ui-dialog' => 'ui-dialog-off-canvas ui-dialog-position-' . ($position ?: 'side'),
    'ui-dialog-content' => 'drupal-off-canvas-reset',
    ],
    'title' => 'AJAX Dialog & contents',
    'modal' => FALSE,
    'autoResize' => FALSE,
    ......@@ -54,8 +58,6 @@ public function testDialog($position) {
    'draggable' => FALSE,
    'drupalAutoButtons' => FALSE,
    'drupalOffCanvasPosition' => $position ?: 'side',
    'dialogClass' => 'ui-dialog-off-canvas ui-dialog-position-' . ($position ?: 'side'),
    'classes' => ['ui-dialog-content' => 'drupal-off-canvas-reset'],
    'width' => 300,
    ],
    'effect' => 'fade',
    ......
    ......@@ -22,7 +22,9 @@ public function modal() {
    'class' => ['use-ajax'],
    'data-dialog-type' => 'modal',
    'data-dialog-options' => Json::encode([
    'dialogClass' => 'views-test-modal',
    'classes' => [
    'ui-dialog' => 'views-test-modal',
    ],
    'height' => '50%',
    'width' => '50%',
    'title' => $this->t('Administer content'),
    ......
    ......@@ -244,7 +244,9 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state)
    $display .= $output;
    $options = [
    'dialogClass' => 'views-ui-dialog js-views-ui-dialog',
    'classes' => [
    'ui-dialog' => 'views-ui-dialog js-views-ui-dialog',
    ],
    'width' => '75%',
    ];
    ......
    ......@@ -34,8 +34,10 @@ public function testRender($position) {
    'resizable' => 'w',
    'draggable' => FALSE,
    'drupalAutoButtons' => FALSE,
    'dialogClass' => 'ui-dialog-off-canvas ui-dialog-position-' . $position,
    'classes' => ['ui-dialog-content' => 'drupal-off-canvas-reset'],
    'classes' => [
    'ui-dialog' => 'ui-dialog-off-canvas ui-dialog-position-' . $position,
    'ui-dialog-content' => 'drupal-off-canvas-reset',
    ],
    'width' => 300,
    'drupalOffCanvasPosition' => $position,
    ],
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment