Skip to content

Commit

Permalink
Reactivate keyboard shortcuts when notifications are closed
Browse files Browse the repository at this point in the history
Fixes #13574
Resolves #13575
  • Loading branch information
brandonkelly committed Aug 21, 2023
1 parent 49af17e commit 3416301
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fixed a bug where icons within secondary buttons were illegible when active.
- Fixed a bug where the `|replace` filter was treating search strings as regular expressions even if they were invalid. ([#12956](https://github.com/craftcms/cms/issues/12956))
- Fixed a bug where user groups without “Edit users” permission were being granted “Assign users to [group name]” when upgrading to Craft 4.
- Fixed a bug where keyboard shortcuts weren’t getting reactivated when control panel notifications were dismissed. ([#13574](https://github.com/craftcms/cms/issues/13574))

## 4.4.17 - 2023-08-08

Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/web/assets/cp/src/js/CP.js
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ Craft.CP.Notification = Garnish.Base.extend({
$container: null,
$closeBtn: null,
originalActiveElement: null,
_hasUiElements: false,

init: function (type, message, settings) {
this.type = type;
Expand Down Expand Up @@ -1533,8 +1534,8 @@ Craft.CP.Notification = Garnish.Base.extend({
.append(this.settings.details)
.appendTo($main);

const $focusableElement = $detailsContainer.find('button,input');
if ($focusableElement.length) {
this._hasUiElements = !!$detailsContainer.find('button,input');
if (this._hasUiElements) {
Garnish.uiLayerManager.addLayer(this.$container);
Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY, () => {
this.close();
Expand Down Expand Up @@ -1609,6 +1610,10 @@ Craft.CP.Notification = Garnish.Base.extend({

this.closing = true;

if (this._hasUiElements) {
Garnish.uiLayerManager.removeLayer(this.$container);
}

if (
this.originalActiveElement &&
document.activeElement &&
Expand Down

0 comments on commit 3416301

Please sign in to comment.