Commit c8290734 authored by alexpott's avatar alexpott Committed by webchick

Issue #2784571 by tedbow, drpal, nod_, naveenvalecha, miteshmap, droplet,...

Issue #2784571 by tedbow, drpal, nod_, naveenvalecha, miteshmap, droplet, Everett Zufelt: Outside-in Accessibility: Allow escape from edit mode with ESC key
parent 22aa4508
......@@ -47,7 +47,7 @@
$element
.dialog('option', adjustedOptions)
.trigger('dialogContentResize.outsidein');
.trigger('dialogContentResize.offcanvas');
}
/**
......@@ -100,15 +100,15 @@
$('.ui-dialog-offcanvas, .ui-dialog-offcanvas .ui-dialog-titlebar').toggleClass('ui-dialog-empty-title', !settings.title);
$element
.on('dialogresize.outsidein', eventData, debounce(bodyPadding, 100))
.on('dialogContentResize.outsidein', eventData, handleDialogResize)
.trigger('dialogresize.outsidein');
.on('dialogresize.offcanvas', eventData, debounce(bodyPadding, 100))
.on('dialogContentResize.offcanvas', eventData, handleDialogResize)
.trigger('dialogresize.offcanvas');
$element.dialog('widget').attr('data-offset-' + edge, '');
$(window)
.on('resize.outsidein scroll.outsidein', eventData, debounce(resetSize, 100))
.trigger('resize.outsidein');
.on('resize.offcanvas scroll.offcanvas', eventData, debounce(resetSize, 100))
.trigger('resize.offcanvas');
}
},
'dialog:beforecreate': function (event, dialog, $element, settings) {
......@@ -127,8 +127,8 @@
},
'dialog:beforeclose': function (event, dialog, $element) {
if ($element.is('#drupal-offcanvas')) {
$(document).off('.outsidein');
$(window).off('.outsidein');
$(document).off('.offcanvas');
$(window).off('.offcanvas');
$mainCanvasWrapper.css('padding-' + edge, 0);
}
}
......
......@@ -42,6 +42,15 @@
});
});
$(document).on('keyup.outsidein', function (e) {
if (isInEditMode() && e.keyCode === 27) {
Drupal.announce(
Drupal.t('Exited edit mode.')
);
toggleEditMode();
}
});
/**
* Gets all items that should be toggled with class during edit mode.
*
......
......@@ -117,8 +117,16 @@ public function testBlocks($block_id, $new_page_text, $element_selector, $label_
// suppressed.
$this->openBlockForm($element_selector);
// Exit edit mode.
$this->toggleEditingMode();
// Exit edit mode using ESC.
$web_assert->elementTextContains('css', '.contextual-toolbar-tab button', 'Editing');
$web_assert->elementAttributeContains('css', '#main-canvas', 'class', 'js-outside-in-edit-mode');
// Simulate press the Escape key.
$this->getSession()->executeScript('jQuery("body").trigger(jQuery.Event("keyup", { keyCode: 27 }));');
$this->waitForOffCanvasToClose();
$this->getSession()->wait(100);
$web_assert->elementTextContains('css', '#drupal-live-announce', 'Exited edit mode.');
$web_assert->elementTextNotContains('css', '.contextual-toolbar-tab button', 'Editing');
$web_assert->elementAttributeNotContains('css', '#main-canvas', 'class', 'js-outside-in-edit-mode');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment