@brightspace-ui/core 1.188.1 → 1.189.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.
@@ -82,7 +82,7 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(L
82
82
  if (this.selectable) {
83
83
  if (!this.key) console.warn('ListItemCheckboxMixin requires a key.');
84
84
  } else {
85
- this._labelRequired = false;
85
+ this.labelRequired = false;
86
86
  }
87
87
  if (!this.key) this.setSelected(undefined, true);
88
88
  }
@@ -124,21 +124,9 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(L
124
124
  }
125
125
  }
126
126
 
127
- _onNestedSlotChange(e) {
128
- if (!this.selectable) return;
129
-
130
- const nestedList = e.target.assignedNodes().find(node => (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'D2L-LIST'));
131
- if (this._selectionProvider === nestedList) return;
132
-
133
- if (this._selectionProvider && this._selectionProvider !== nestedList) {
134
- this._selectionProvider.unsubscribeObserver(this);
135
- this._selectionProvider = null;
136
- }
137
-
138
- if (nestedList) {
139
- this._selectionProvider = nestedList;
140
- this._selectionProvider.subscribeObserver(this);
141
- }
127
+ _onSelectionProviderConnected(e) {
128
+ e.stopPropagation();
129
+ this._updateNestedSelectionProvider();
142
130
  }
143
131
 
144
132
  _renderCheckbox() {
@@ -169,4 +157,29 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(L
169
157
  </div>
170
158
  ` : nothing;
171
159
  }
160
+
161
+ _updateNestedSelectionProvider() {
162
+ if (!this.selectable) return;
163
+
164
+ const nestedSlot = this.shadowRoot.querySelector('slot[name="nested"]');
165
+ let nestedNodes = nestedSlot.assignedNodes();
166
+ if (nestedNodes.length === 0) {
167
+ nestedNodes = [...nestedSlot.childNodes];
168
+ }
169
+
170
+ const nestedList = nestedNodes.find(node => (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'D2L-LIST'));
171
+
172
+ if (this._selectionProvider === nestedList) return;
173
+
174
+ if (this._selectionProvider && this._selectionProvider !== nestedList) {
175
+ this._selectionProvider.unsubscribeObserver(this);
176
+ this._selectionProvider = null;
177
+ }
178
+
179
+ if (nestedList) {
180
+ this._selectionProvider = nestedList;
181
+ this._selectionProvider.subscribeObserver(this);
182
+ }
183
+ }
184
+
172
185
  };
@@ -333,7 +333,7 @@ export const ListItemMixin = superclass => class extends ListItemDragDropMixin(L
333
333
  this._hovering = false;
334
334
  }
335
335
 
336
- _renderListItem({ illustration, content, actions } = {}) {
336
+ _renderListItem({ illustration, content, actions, nested } = {}) {
337
337
  const classes = {
338
338
  'd2l-visible-on-ancestor-target': true,
339
339
  'd2l-list-item-content-extend-separators': this._extendSeparators,
@@ -388,8 +388,8 @@ export const ListItemMixin = superclass => class extends ListItemDragDropMixin(L
388
388
  class="d2l-list-item-actions-container">
389
389
  <slot name="actions" class="d2l-list-item-actions">${actions}</slot>
390
390
  </div>
391
- <div slot="nested">
392
- <slot name="nested" @slotchange="${this._onNestedSlotChange}"></slot>
391
+ <div slot="nested" @d2l-selection-provider-connected="${this._onSelectionProviderConnected}">
392
+ <slot name="nested">${nested}</slot>
393
393
  </div>
394
394
  </d2l-list-item-generic-layout>
395
395
  <div class="d2l-list-item-active-border"></div>
@@ -59,6 +59,10 @@ export const SelectionMixin = superclass => class extends RtlMixin(superclass) {
59
59
  this.addEventListener('d2l-selection-change', this._handleSelectionChange);
60
60
  this.addEventListener('d2l-selection-observer-subscribe', this._handleSelectionObserverSubscribe);
61
61
  this.addEventListener('d2l-selection-input-subscribe', this._handleSelectionInputSubscribe);
62
+ requestAnimationFrame(() => {
63
+ this.dispatchEvent(new CustomEvent('d2l-selection-provider-connected', { bubbles: true, composed: true }));
64
+ });
65
+
62
66
  }
63
67
 
64
68
  disconnectedCallback() {