@brightspace-ui/core 3.286.0 → 3.286.2

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.
@@ -186,9 +186,17 @@ export const DropdownPopoverMixin = superclass => class extends LocalizeCoreElem
186
186
  this._hasHeaderSlotContent = false;
187
187
  }
188
188
 
189
+ disconnectedCallback() {
190
+ super.disconnectedCallback();
191
+ this.#resizeObserver.disconnect();
192
+ }
193
+
189
194
  firstUpdated(changedProperties) {
190
195
  super.firstUpdated(changedProperties);
191
196
  this.#contentElement = this.shadowRoot?.querySelector('.dropdown-content');
197
+ if (this.#contentElement) {
198
+ this.#resizeObserver.observe(this.#contentElement);
199
+ }
192
200
  this.addEventListener('d2l-popover-open', this.#handlePopoverOpen);
193
201
  this.addEventListener('d2l-popover-close', this.#handlePopoverClose);
194
202
  this.addEventListener('d2l-popover-position', this.#handlePopoverPosition);
@@ -291,6 +299,9 @@ export const DropdownPopoverMixin = superclass => class extends LocalizeCoreElem
291
299
  }
292
300
 
293
301
  #contentElement;
302
+ #resizeObserver = new ResizeObserver(() => {
303
+ this.#toggleScrollStyles();
304
+ });
294
305
 
295
306
  #adaptMobileTrayLocation(val) {
296
307
  switch (val) {
@@ -11,8 +11,8 @@ const VALID_STATE_STORAGE_KEY = /^[a-z0-9_-]+$/i;
11
11
  export const panelStateStorageKey = key => `d2l-page-panel-state-${key}`;
12
12
 
13
13
  const DRAWER_MIN_HEIGHT = 200; // TO DO: Confirm
14
- const MAIN_MIN_WIDTH = 600; // TO DO: Confirm
15
- const PANEL_MIN_WIDTH = 320;
14
+ export const MAIN_MIN_WIDTH = 600; // TO DO: Confirm
15
+ export const PANEL_MIN_WIDTH = 320;
16
16
 
17
17
  export const SIDE_NAV_DEFAULT_WIDTH = 334;
18
18
  export const supportingDefaultWidth = contentWidth => Math.floor(contentWidth / 3);
package/helpers/README.md CHANGED
@@ -89,6 +89,10 @@ findComposedAncestor(node, predicate);
89
89
  // includes optional predicate for filtering child elements
90
90
  getComposedChildren(element, predicate = () => true);
91
91
 
92
+ //gets the composed next ancestor sibling by walking the composed ancestors
93
+ // includes optional predicate for filtering elements
94
+ getComposedNextAncestorElementSibling(node, { predicate });
95
+
92
96
  // gets the composed next element sibling considing how children are distributed into slots
93
97
  // includes optional predicate for filtering elements
94
98
  getComposedNextElementSibling(node, { predicate });
@@ -96,6 +100,10 @@ getComposedNextElementSibling(node, { predicate });
96
100
  // gets the composed parent (including shadow host & insertion points)
97
101
  getComposedParent(node);
98
102
 
103
+ //gets the composed previous ancestor sibling by walking the composed ancestors
104
+ // includes optional predicate for filtering elements
105
+ getComposedPreviousAncestorElementSibling(node, { predicate });
106
+
99
107
  // gets the composed previous element sibling considing how children are distributed into slots
100
108
  // includes optional predicate for filtering elements
101
109
  getComposedPreviousElementSibling(node, { predicate });
@@ -103,14 +111,6 @@ getComposedPreviousElementSibling(node, { predicate });
103
111
  // returns the first visible ancestor of the given node
104
112
  getFirstVisibleAncestor(node)
105
113
 
106
- // returns the next composed sibling at least one dom level up
107
- // includes optional predicate for filtering elements
108
- getNextAncestorSibling(node, predicate = () => true);
109
-
110
- // returns the previous composed sibling at least one dom level up
111
- // includes optional predicate for filtering elements
112
- getPreviousAncestorSibling(node, predicate = () => true);
113
-
114
114
  // browser consistent implementation of HTMLElement.offsetParent
115
115
  getOffsetParent(node);
116
116
 
package/helpers/dom.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { getFlag } from './flags.js';
2
+
1
3
  // needed for legacy-Edge, after it's removed use CSS.escape directly
2
4
  export function cssEscape(val) {
3
5
  if (window.CSS && window.CSS.escape) {
@@ -148,6 +150,22 @@ function getComposedElementSibling(node, { direction = 'next', predicate } = {})
148
150
  return null;
149
151
  }
150
152
 
153
+ export function getComposedNextAncestorElementSibling(node, { predicate } = {}) {
154
+
155
+ const focusableFixFlag = getFlag('GAUD-10260-get-focusable-fix', true);
156
+
157
+ let parentNode = getComposedParent(node);
158
+
159
+ while (parentNode) {
160
+ // Clean-up this next line when cleaning up GAUD-10260-get-focusable-fix
161
+ const nextParentSibling = focusableFixFlag ? getComposedNextElementSibling(parentNode, { predicate }) : parentNode.nextElementSibling;
162
+ if (nextParentSibling) return nextParentSibling;
163
+ parentNode = getComposedParent(parentNode);
164
+ }
165
+
166
+ return null;
167
+ }
168
+
151
169
  export function getComposedNextElementSibling(node, { predicate } = {}) {
152
170
  return getComposedElementSibling(node, { direction: 'next', predicate });
153
171
  }
@@ -175,32 +193,24 @@ export function getComposedParent(node) {
175
193
 
176
194
  }
177
195
 
178
- export function getComposedPreviousElementSibling(node, { predicate } = {}) {
179
- return getComposedElementSibling(node, { direction: 'previous', predicate });
180
- }
196
+ export function getComposedPreviousAncestorElementSibling(node, { predicate } = {}) {
197
+
198
+ const focusableFixFlag = getFlag('GAUD-10260-get-focusable-fix', true);
181
199
 
182
- export function getNextAncestorSibling(node, predicate = () => true) {
183
200
  let parentNode = getComposedParent(node);
184
201
 
185
202
  while (parentNode) {
186
- const nextParentSibling = parentNode.nextElementSibling;
187
- if (nextParentSibling && predicate(nextParentSibling)) return nextParentSibling;
203
+ // Clean-up this next line when cleaning up GAUD-10260-get-focusable-fix
204
+ const previousParentSibling = focusableFixFlag ? getComposedPreviousElementSibling(parentNode, { predicate }) : parentNode.previousElementSibling;
205
+ if (previousParentSibling) return previousParentSibling;
188
206
  parentNode = getComposedParent(parentNode);
189
207
  }
190
208
 
191
209
  return null;
192
210
  }
193
211
 
194
- export function getPreviousAncestorSibling(node, predicate = () => true) {
195
- let parentNode = getComposedParent(node);
196
-
197
- while (parentNode) {
198
- const previousParentSibling = parentNode.previousElementSibling;
199
- if (previousParentSibling && predicate(previousParentSibling)) return previousParentSibling;
200
- parentNode = getComposedParent(parentNode);
201
- }
202
-
203
- return null;
212
+ export function getComposedPreviousElementSibling(node, { predicate } = {}) {
213
+ return getComposedElementSibling(node, { direction: 'previous', predicate });
204
214
  }
205
215
 
206
216
  export function getOffsetParent(node) {
package/helpers/focus.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import { css, unsafeCSS } from 'lit';
2
- import { getComposedChildren, getComposedParent, getFirstVisibleAncestor, getNextAncestorSibling, getPreviousAncestorSibling, isVisible } from './dom.js';
2
+ import {
3
+ getComposedChildren,
4
+ getComposedNextAncestorElementSibling,
5
+ getComposedNextElementSibling,
6
+ getComposedParent,
7
+ getComposedPreviousAncestorElementSibling,
8
+ getComposedPreviousElementSibling,
9
+ getFirstVisibleAncestor,
10
+ isVisible
11
+ } from './dom.js';
12
+ import { getFlag } from './flags.js';
3
13
 
4
14
  const focusableElements = {
5
15
  a: true,
@@ -123,6 +133,9 @@ export function getLastFocusableDescendant(node, includeHidden) {
123
133
  }
124
134
 
125
135
  export function getPreviousFocusable(node, includeHidden) {
136
+
137
+ const focusableFixFlag = getFlag('GAUD-10260-get-focusable-fix', true);
138
+
126
139
  if (!node) return null;
127
140
 
128
141
  if (includeHidden === undefined) includeHidden = false;
@@ -135,14 +148,15 @@ export function getPreviousFocusable(node, includeHidden) {
135
148
  if (focusable) return focusable;
136
149
  }
137
150
 
138
- const previousSibling = node.previousElementSibling;
151
+ // Clean-up this next line when cleaning up GAUD-10260-get-focusable-fix
152
+ const previousSibling = focusableFixFlag ? getComposedPreviousElementSibling(node) : node.previousElementSibling;
139
153
  if (previousSibling) {
140
154
  const siblingFocusable = _getPreviousFocusable(previousSibling, false, false);
141
155
  if (siblingFocusable) return siblingFocusable;
142
156
  return null;
143
157
  }
144
158
 
145
- const previousAncestorSibling = getPreviousAncestorSibling(node);
159
+ const previousAncestorSibling = getComposedPreviousAncestorElementSibling(node);
146
160
  if (previousAncestorSibling) {
147
161
  const parentSibingFocusable = _getPreviousFocusable(previousAncestorSibling, false, false);
148
162
  if (parentSibingFocusable) return parentSibingFocusable;
@@ -157,6 +171,8 @@ export function getPreviousFocusable(node, includeHidden) {
157
171
 
158
172
  export function getNextFocusable(node, includeHidden, ignore, ignoreChildren) {
159
173
 
174
+ const focusableFixFlag = getFlag('GAUD-10260-get-focusable-fix', true);
175
+
160
176
  if (!node) return null;
161
177
 
162
178
  if (includeHidden === undefined) includeHidden = false;
@@ -171,14 +187,15 @@ export function getNextFocusable(node, includeHidden, ignore, ignoreChildren) {
171
187
  if (focusable) return focusable;
172
188
  }
173
189
 
174
- const nextSibling = node.nextElementSibling;
190
+ // Clean-up this next line when cleaning up GAUD-10260-get-focusable-fix
191
+ const nextSibling = focusableFixFlag ? getComposedNextElementSibling(node) : node.nextElementSibling;
175
192
  if (nextSibling) {
176
193
  const siblingFocusable = _getNextFocusable(nextSibling, false, false);
177
194
  if (siblingFocusable) return siblingFocusable;
178
195
  return null;
179
196
  }
180
197
 
181
- const nextParentSibling = getNextAncestorSibling(node);
198
+ const nextParentSibling = getComposedNextAncestorElementSibling(node);
182
199
  if (nextParentSibling) {
183
200
  const parentSibingFocusable = _getNextFocusable(nextParentSibling, false, false);
184
201
  if (parentSibingFocusable) return parentSibingFocusable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.286.0",
3
+ "version": "3.286.2",
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",