@brightspace-ui/core 2.118.2 → 2.118.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.
@@ -381,7 +381,7 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
381
381
 
382
382
  _dispatchListItemsMove(sourceItems, targetItem, moveLocation, keyboardActive) {
383
383
  if (!keyboardActive) keyboardActive = false;
384
- const rootList = this._getRootList();
384
+ const rootList = this.getRootList();
385
385
  /** @ignore */
386
386
  rootList.dispatchEvent(new CustomEvent('d2l-list-items-move', {
387
387
  detail: {
@@ -408,13 +408,13 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
408
408
  }
409
409
 
410
410
  _dispatchMoveListItemFirst(moveToRoot) {
411
- const list = (moveToRoot ? this._getRootList() : findComposedAncestor(this, node => node.tagName === 'D2L-LIST'));
411
+ const list = (moveToRoot ? this.getRootList() : findComposedAncestor(this, node => node.tagName === 'D2L-LIST'));
412
412
  const items = list.getItems();
413
413
  this._dispatchListItemsMove([this], items[0], moveLocations.above, true);
414
414
  }
415
415
 
416
416
  _dispatchMoveListItemLast(moveToRoot) {
417
- const list = (moveToRoot ? this._getRootList() : findComposedAncestor(this, node => node.tagName === 'D2L-LIST'));
417
+ const list = (moveToRoot ? this.getRootList() : findComposedAncestor(this, node => node.tagName === 'D2L-LIST'));
418
418
  const items = list.getItems();
419
419
  this._dispatchListItemsMove([this], items[items.length - 1], moveLocations.below, true);
420
420
  }
@@ -483,7 +483,7 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
483
483
  }
484
484
 
485
485
  _dispatchMoveRootItem(moveAbove) {
486
- const rootList = this._getRootList();
486
+ const rootList = this.getRootList();
487
487
  const items = rootList.getItems();
488
488
  const currentIndex = items.indexOf(this);
489
489
  if (moveAbove && currentIndex !== 0) {
@@ -610,7 +610,7 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
610
610
  return dragImage;
611
611
  };
612
612
 
613
- const rootList = this._getRootList(this);
613
+ const rootList = this.getRootList(this);
614
614
  const selectionInfo = rootList.getSelectionInfo(rootList.dragMultiple);
615
615
  if (rootList.dragMultiple && selectionInfo.keys.length > 1) {
616
616
  const lazyLoadListItems = this._getFlattenedListItems().lazyLoadListItems;
@@ -750,8 +750,8 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
750
750
  }
751
751
 
752
752
  // assert that both the source and target are from the same list - may allow this in the future
753
- const targetRoot = dragState.dragTargets[0] && dragState.dragTargets[0]._getRootList();
754
- if (this._getRootList() !== targetRoot) return;
753
+ const targetRoot = dragState.dragTargets[0] && dragState.dragTargets[0].getRootList();
754
+ if (this.getRootList() !== targetRoot) return;
755
755
 
756
756
  dragState.addDropTarget(this);
757
757
  this._draggingOver = true;
@@ -283,7 +283,8 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
283
283
 
284
284
  _focusNextRow(previous = false, num = 1) {
285
285
 
286
- let listItem = findComposedAncestor(this, node => node.role === 'rowgroup');
286
+ const curListItem = findComposedAncestor(this, node => node.role === 'rowgroup');
287
+ let listItem = curListItem;
287
288
 
288
289
  while (num > 0) {
289
290
  const tempListItem = (previous ? this._getPreviousFlattenedListItem(listItem) : this._getNextFlattenedListItem(listItem));
@@ -301,7 +302,9 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
301
302
  if (!listItem._tryFocus()) {
302
303
  // ultimate fallback to generic method for getting next/previous focusable
303
304
  const nextFocusable = previous ? getPreviousFocusable(listItem) : getNextFocusable(listItem);
304
- if (nextFocusable) nextFocusable.focus();
305
+ if (nextFocusable && this._isContainedInSameRootList(curListItem, nextFocusable)) {
306
+ nextFocusable.focus();
307
+ }
305
308
  }
306
309
  }
307
310
 
@@ -442,9 +445,13 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
442
445
  this.shadowRoot.querySelector(`.d2l-cell[data-cell-num="${this._cellNum}"]`);
443
446
  }
444
447
 
448
+ _isContainedInSameRootList(item, node) {
449
+ const rootList = item?.getRootList?.(item);
450
+ return isComposedAncestor(rootList, node);
451
+ }
452
+
445
453
  _onKeydown(event) {
446
454
  if (!this.gridActive) return;
447
-
448
455
  let node = null;
449
456
  let preventDefault = true;
450
457
  switch (event.keyCode) {
@@ -440,6 +440,16 @@ export const ListItemMixin = superclass => class extends composeMixins(
440
440
  this._tryFocus();
441
441
  }
442
442
 
443
+ getRootList(node) {
444
+ if (!node) node = this;
445
+ let rootList;
446
+ while (node) {
447
+ if (node.tagName === 'D2L-LIST') rootList = node;
448
+ node = getComposedParent(node);
449
+ }
450
+ return rootList;
451
+ }
452
+
443
453
  async highlight() {
444
454
  if (this._highlight) return;
445
455
  const elem = this.shadowRoot.querySelector('[slot="outside-control-container"]');
@@ -487,7 +497,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
487
497
 
488
498
  _getListItems(listItems, lazyLoadListItems, listItem) {
489
499
  if (!listItem) {
490
- const rootList = this._getRootList();
500
+ const rootList = this.getRootList();
491
501
  const rootListItems = rootList.getItems();
492
502
  rootListItems.forEach(listItem => this._getListItems(listItems, lazyLoadListItems, listItem));
493
503
  } else {
@@ -544,16 +554,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
544
554
  }
545
555
  }
546
556
 
547
- _getRootList(node) {
548
- if (!node) node = this;
549
- let rootList;
550
- while (node) {
551
- if (node.tagName === 'D2L-LIST') rootList = node;
552
- node = getComposedParent(node);
553
- }
554
- return rootList;
555
- }
556
-
557
557
  _isListItem(node) {
558
558
  if (!node) node = this;
559
559
  return node.role === 'rowgroup' || node.role === 'listitem';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.118.2",
3
+ "version": "2.118.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",