Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions js/a11y/popup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Adapt from 'core/js/adapt';
import logging from '../logging';
import wait from 'core/js/wait';

/**
* Tabindex and aria-hidden manager for popups.
Expand Down Expand Up @@ -146,12 +147,16 @@ export default class Popup extends Backbone.Controller {
* Close the last popup on the stack, restoring tabindex and aria-hidden
* attributes.
*
* @param {Object} [$focusElement] Element at which to move focus.
* @param {Object} [$forceFocusElement] Element at which to move focus.
* @returns {Object} Returns `a11y._popup`.
*/
closed($focusElement, silent) {
async closed($forceFocusElement, silent) {
if (!silent) {
Adapt.trigger('popup:closing');
await wait.queue();
}
const $previousFocusElement = this._removeLastPopupLayer();
$focusElement = $focusElement || $previousFocusElement || $('body');
const $focusElement = $forceFocusElement || $previousFocusElement || $('body');
if (!silent) {
Adapt.trigger('popup:closed', $focusElement, true);
}
Expand Down
4 changes: 1 addition & 3 deletions js/views/notifyPopupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ export default class NotifyPopupView extends Backbone.View {
await this.addSubView();
// Add to the list of open popups
this.notify.stack.push(this);
// Keep focus from previous action
this.$previousActiveElement = $(document.activeElement);
Adapt.trigger('notify:opened', this);
this.$el.imageready(this.onLoaded.bind(this));
}
Expand Down Expand Up @@ -203,7 +201,7 @@ export default class NotifyPopupView extends Backbone.View {
a11y.scrollEnable('body');
$('html').removeClass('notify');
// Return focus to previous active element
a11y.popupClosed(this.$previousActiveElement);
await a11y.popupClosed();
// Return reference to the notify view
Adapt.trigger('notify:closed', this);
}
Expand Down