@brightspace-ui/core 2.159.2 → 2.159.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,8 @@ import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  import { isComposedAncestor } from '../../helpers/dom.js';
6
6
 
7
+ const traps = [];
8
+
7
9
  /**
8
10
  * A generic container component to trap user focus.
9
11
  * @fires d2l-focus-trap-enter - Dispatched when focus enters the trap. May be used to override initial focus placement when focus enters the trap.
@@ -68,6 +70,17 @@ class FocusTrap extends FocusMixin(LitElement) {
68
70
  `;
69
71
  }
70
72
 
73
+ willUpdate(changedProperties) {
74
+ if (!changedProperties.has('trap')) return;
75
+ if (this.trap) {
76
+ traps.push(this);
77
+ } else {
78
+ const trapIndex = traps.findIndex(trap => trap === this);
79
+ if (trapIndex === -1) return;
80
+ traps.splice(trapIndex, 1);
81
+ }
82
+ }
83
+
71
84
  _focusFirst() {
72
85
  const focusable = this.shadowRoot &&
73
86
  getNextFocusable(this.shadowRoot.querySelector('.d2l-focus-trap-start'));
@@ -80,7 +93,8 @@ class FocusTrap extends FocusMixin(LitElement) {
80
93
  }
81
94
 
82
95
  _handleBodyFocus(e) {
83
- if (!this.trap || this._legacyPromptIds.size > 0) return;
96
+ const lastTrap = traps[traps.length - 1];
97
+ if (!this.trap || this._legacyPromptIds.size > 0 || lastTrap !== this) return;
84
98
  const container = this._getContainer();
85
99
  const target = e.composedPath()[0];
86
100
  if (isComposedAncestor(container, target)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.159.2",
3
+ "version": "2.159.3",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",