-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Subject of the issue
When opening a notify, it captures the document.activeElement
to return there upon closing. There is no easy way to change the element that should be focused after the notify closes.
This feature was introduced in 2018 in this commit, with the following lines in play:
adapt-contrib-core/js/views/notifyView.js
Line 141 in 244af2a
this.$previousActiveElement = $(document.activeElement); |
adapt-contrib-core/js/views/notifyView.js
Line 228 in 244af2a
Adapt.trigger('popup:closed notify:closed', this.$previousActiveElement); |
adapt-contrib-core/js/popupManager.js
Lines 14 to 22 in 73ef217
Adapt.on('popup:closed', function($target) { | |
//restore tab indexes | |
var $launchedElement = $.a11y_popdown(); | |
var $activeElement = $target || $launchedElement; | |
if ($activeElement) { | |
return $activeElement.focusOrNext(); | |
} |
And can be seen in today's code at these lines:
this.$previousActiveElement = $(document.activeElement); |
a11y.popupClosed(this.$previousActiveElement); |
adapt-contrib-core/js/a11y/popup.js
Lines 152 to 158 in e7fe240
closed($focusElement, silent) { | |
const $previousFocusElement = this._removeLastPopupLayer(); | |
$focusElement = $focusElement || $previousFocusElement || $('body'); | |
if (!silent) { | |
Adapt.trigger('popup:closed', $focusElement, true); | |
} | |
this.a11y.focusFirst($($focusElement), { preventScroll: true }); |
It would be ideal if we could use the a11y.setPopupCloseTo
for the notify:
Lines 909 to 918 in e7fe240
/** | |
* When a popup is open, this function makes it possible to swap the element | |
* that should receive focus on popup close. | |
* | |
* @param {Object} $focusElement Set a new element to focus on. | |
* @returns {Object} Returns previously set focus element. | |
*/ | |
setPopupCloseTo($focusElement) { | |
return this._popup.setCloseTo($focusElement); | |
} |
adapt-contrib-core/js/a11y/popup.js
Lines 230 to 233 in e7fe240
setCloseTo($focusElement) { | |
const $original = this._focusStack.pop(); | |
this._focusStack.push($focusElement); | |
return $original; |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status