@brightspace-ui/core 2.159.2 → 2.160.0

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;
@@ -21,7 +21,7 @@ A switch is used to toggle between two states, on and off, just like a light swi
21
21
  <!-- docs: end dos -->
22
22
 
23
23
  <!-- docs: start donts -->
24
- * Don't toggle the language in the label, it should remain stati
24
+ * Don't toggle the language in the label, it should remain static
25
25
  * Don't use a switch in a form, use a checkbox or radio options in stead
26
26
  <!-- docs: end donts -->
27
27
  <!-- docs: end best practices -->
@@ -89,7 +89,7 @@ See also [Visibility Switch with Conditions](https://daylight.d2l.dev/components
89
89
  ### Slots
90
90
 
91
91
  - Optional default slot content - Content that will be displayed within the "conditions" opener tooltip when the switch is on.
92
-
92
+
93
93
  <!-- docs: end hidden content -->
94
94
 
95
95
  ### Visibility Switch with Conditions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.159.2",
3
+ "version": "2.160.0",
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",