@brightspace-ui/core 2.137.0 → 2.137.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.
@@ -184,6 +184,12 @@
184
184
  <d2l-list-item selectable key="3" label="Geomorphology and GIS">
185
185
  <d2l-list-item-content>Geomorphology and GIS</d2l-list-item-content>
186
186
  </d2l-list-item>
187
+ <d2l-list-item selectable key="4" label="Introductory Differential Equations">
188
+ <d2l-list-item-content>Introductory Differential Equations</d2l-list-item-content>
189
+ </d2l-list-item>
190
+ <d2l-list-item selectable key="5" label="Fermentation Biology">
191
+ <d2l-list-item-content>Fermentation Biology</d2l-list-item-content>
192
+ </d2l-list-item>
187
193
  </d2l-list>
188
194
  </template>
189
195
  </d2l-demo-snippet>
@@ -102,6 +102,7 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
102
102
 
103
103
  ::slotted([slot="control"]) {
104
104
  grid-column: control-start / control-end;
105
+ pointer-events: none;
105
106
  width: 2.2rem;
106
107
  }
107
108
 
@@ -109,11 +110,6 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
109
110
  grid-column: content-start / content-end;
110
111
  }
111
112
 
112
- ::slotted([slot="control"]),
113
- ::slotted([slot="outside-control"]) {
114
- pointer-events: none;
115
- }
116
-
117
113
  ::slotted([slot="control-action"]) ~ ::slotted([slot="content"]),
118
114
  ::slotted([slot="outside-control-action"]) ~ ::slotted([slot="content"]) {
119
115
  pointer-events: unset;
@@ -200,8 +196,8 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
200
196
  <slot name="outside-control-container"></slot>
201
197
 
202
198
  <slot name="content-action" class="d2l-cell" data-cell-num="6"></slot>
203
- <slot name="outside-control-action" class="d2l-cell" data-cell-num="1"></slot>
204
199
  <slot name="outside-control" class="d2l-cell" data-cell-num="2"></slot>
200
+ <slot name="outside-control-action" class="d2l-cell" data-cell-num="1"></slot>
205
201
  <slot name="expand-collapse" class="d2l-cell" data-cell-num="4"></slot>
206
202
  <slot name="content" class="d2l-cell" data-cell-num="8" @focus="${!this.noPrimaryAction ? this._preventFocus : null}"></slot>
207
203
  <slot name="control-action" class="d2l-cell" data-cell-num="3"></slot>
@@ -1,4 +1,6 @@
1
+ import { getFirstFocusableDescendant, getLastFocusableDescendant, getNextFocusable, getPreviousFocusable } from '../../helpers/focus.js';
1
2
  import { CollectionMixin } from '../../mixins/collection/collection-mixin.js';
3
+ import { isComposedAncestor } from '../../helpers/dom.js';
2
4
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
3
5
 
4
6
  const keyCodes = {
@@ -152,29 +154,43 @@ export const SelectionMixin = superclass => class extends RtlMixin(CollectionMix
152
154
  }
153
155
 
154
156
  _handleRadioKeyUp(e) {
157
+
158
+ const target = e.composedPath()[0];
159
+
155
160
  // check composed path for radio (e.target could be d2l-list-item or other element due to retargeting)
156
- if (!e.composedPath()[0].classList.contains('d2l-selection-input-radio')) return;
161
+ if (!target.classList.contains('d2l-selection-input-radio')) return;
157
162
  if (e.keyCode < keyCodes.LEFT || e.keyCode > keyCodes.DOWN) return;
158
163
 
159
- const selectables = Array.from(this._selectionSelectables.values())
160
- .filter(item => !item.disabled);
161
- let currentIndex = selectables.findIndex(selectable => selectable.selected);
162
- if (currentIndex === -1) currentIndex = 0;
163
- let newIndex;
164
-
165
- if ((this.dir !== 'rtl' && e.keyCode === keyCodes.RIGHT)
166
- || (this.dir === 'rtl' && e.keyCode === keyCodes.LEFT)
167
- || e.keyCode === keyCodes.DOWN) {
168
- if (currentIndex === selectables.length - 1) newIndex = 0;
169
- else newIndex = currentIndex + 1;
170
- } else if ((this.dir !== 'rtl' && e.keyCode === keyCodes.LEFT)
171
- || (this.dir === 'rtl' && e.keyCode === keyCodes.RIGHT)
172
- || e.keyCode === keyCodes.UP) {
173
- if (currentIndex === 0) newIndex = selectables.length - 1;
174
- else newIndex = currentIndex - 1;
164
+ const getSelectionInput = (focusable, forward) => {
165
+ while (focusable) {
166
+ if (focusable.classList.contains('d2l-selection-input-radio')) {
167
+ const selectionInput = focusable.getRootNode().host;
168
+ if (!selectionInput.disabled && this._selectionSelectables.has(selectionInput)) return selectionInput;
169
+ }
170
+
171
+ if (!isComposedAncestor(this, focusable)) return null;
172
+
173
+ focusable = forward ? getNextFocusable(focusable, false, true, true) : getPreviousFocusable(focusable, false, true, true);
174
+ }
175
+ };
176
+
177
+ const forward = (this.dir !== 'rtl' && e.keyCode === keyCodes.RIGHT) || (this.dir === 'rtl' && e.keyCode === keyCodes.LEFT) || (e.keyCode === keyCodes.DOWN);
178
+
179
+ // first try to find next/previous selection-input relative to the event target within the selection component sub-tree that also belongs to the selection component
180
+ let focusable = forward ? getNextFocusable(target, false, true, true) : getPreviousFocusable(target, false, true, true);
181
+ let selectionInput = getSelectionInput(focusable, forward);
182
+
183
+ if (!selectionInput) {
184
+ // no selection-input since next/previous focusable is before/after list... cycle to first/last
185
+ focusable = forward ? getFirstFocusableDescendant(this, false) : getLastFocusableDescendant(this, false);
186
+ selectionInput = getSelectionInput(focusable, forward);
175
187
  }
176
- selectables[newIndex].selected = true;
177
- selectables[newIndex].focus();
188
+
189
+ if (selectionInput) {
190
+ selectionInput.selected = true;
191
+ selectionInput.focus();
192
+ }
193
+
178
194
  }
179
195
 
180
196
  _handleSelectionChange(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.137.0",
3
+ "version": "2.137.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",