@brightspace-ui/core 3.94.2 → 3.94.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.
- package/components/tabs/tabs.js +80 -23
- package/package.json +1 -1
package/components/tabs/tabs.js
CHANGED
@@ -242,33 +242,61 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
242
242
|
super.firstUpdated(changedProperties);
|
243
243
|
|
244
244
|
this.arrowKeysFocusablesProvider = async() => {
|
245
|
-
return [...this.shadowRoot.querySelectorAll('d2l-tab-internal')];
|
245
|
+
return this._defaultSlotBehavior ? [...this.shadowRoot.querySelectorAll('d2l-tab-internal')] : this._tabs;
|
246
246
|
};
|
247
247
|
|
248
248
|
this.arrowKeysOnBeforeFocus = async(tab) => {
|
249
|
-
|
250
|
-
|
249
|
+
if (this._defaultSlotBehavior) {
|
250
|
+
// remove this section after d2l-tab/d2l-tab-panel backport
|
251
|
+
const tabInfo = this._getTabInfo(tab.controlsPanel);
|
252
|
+
this._setFocusableDefaultSlotBehavior(tabInfo);
|
251
253
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
if (!this._scrollCollapsed) {
|
256
|
-
return this._updateScrollPositionDefaultSlotBehavior(tabInfo);
|
257
|
-
} else {
|
258
|
-
const measures = this._getMeasures();
|
259
|
-
const newTranslationValue = this._calculateScrollPositionDefaultSlotBehavior(tabInfo, measures);
|
254
|
+
this.requestUpdate();
|
255
|
+
await this.updateComplete;
|
260
256
|
|
261
|
-
if (!this
|
262
|
-
|
257
|
+
if (!this._scrollCollapsed) {
|
258
|
+
return this._updateScrollPositionDefaultSlotBehavior(tabInfo);
|
263
259
|
} else {
|
264
|
-
|
260
|
+
const measures = this._getMeasures();
|
261
|
+
const newTranslationValue = this._calculateScrollPositionDefaultSlotBehavior(tabInfo, measures);
|
262
|
+
|
263
|
+
if (!this.#isRTL()) {
|
264
|
+
if (newTranslationValue >= 0) return;
|
265
|
+
} else {
|
266
|
+
if (newTranslationValue <= 0) return;
|
267
|
+
}
|
268
|
+
|
269
|
+
const expanded = await this._tryExpandTabsContainer(measures);
|
270
|
+
if (expanded) {
|
271
|
+
return;
|
272
|
+
} else {
|
273
|
+
return this._updateScrollPositionDefaultSlotBehavior(tabInfo);
|
274
|
+
}
|
265
275
|
}
|
276
|
+
} else {
|
277
|
+
this._setFocusable(tab);
|
266
278
|
|
267
|
-
|
268
|
-
|
269
|
-
|
279
|
+
this.requestUpdate();
|
280
|
+
await this.updateComplete;
|
281
|
+
|
282
|
+
if (!this._scrollCollapsed) {
|
283
|
+
return this._updateScrollPosition(tab);
|
270
284
|
} else {
|
271
|
-
|
285
|
+
const measures = this._getMeasures();
|
286
|
+
const newTranslationValue = this._calculateScrollPosition(tab, measures);
|
287
|
+
|
288
|
+
if (!this.#isRTL()) {
|
289
|
+
if (newTranslationValue >= 0) return;
|
290
|
+
} else {
|
291
|
+
if (newTranslationValue <= 0) return;
|
292
|
+
}
|
293
|
+
|
294
|
+
const expanded = await this._tryExpandTabsContainer(measures);
|
295
|
+
if (expanded) {
|
296
|
+
return;
|
297
|
+
} else {
|
298
|
+
return this._updateScrollPosition(tab);
|
299
|
+
}
|
272
300
|
}
|
273
301
|
}
|
274
302
|
};
|
@@ -411,6 +439,21 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
411
439
|
}
|
412
440
|
|
413
441
|
async _focusSelected() {
|
442
|
+
if (this._defaultSlotBehavior) {
|
443
|
+
this._focusSelectedDefaultSlotBehavior();
|
444
|
+
return;
|
445
|
+
}
|
446
|
+
|
447
|
+
const selectedTab = this._tabs.find(ti => ti.selected);
|
448
|
+
if (!selectedTab) return;
|
449
|
+
|
450
|
+
await this._updateScrollPosition(selectedTab);
|
451
|
+
|
452
|
+
selectedTab.focus();
|
453
|
+
}
|
454
|
+
|
455
|
+
// remove after d2l-tab/d2l-tab-panel backport
|
456
|
+
async _focusSelectedDefaultSlotBehavior() {
|
414
457
|
const selectedTab = this.shadowRoot && this.shadowRoot.querySelector('d2l-tab-internal[aria-selected="true"]');
|
415
458
|
if (!selectedTab) return;
|
416
459
|
|
@@ -498,7 +541,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
498
541
|
};
|
499
542
|
if (tabInfo.selected) {
|
500
543
|
selectedTabInfo = tabInfo;
|
501
|
-
this.
|
544
|
+
this._setFocusableDefaultSlotBehavior(tabInfo);
|
502
545
|
}
|
503
546
|
return tabInfo;
|
504
547
|
});
|
@@ -566,7 +609,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
566
609
|
// event could be from nested tabs
|
567
610
|
if (!tabInfo) return;
|
568
611
|
|
569
|
-
this.
|
612
|
+
this._setFocusableDefaultSlotBehavior(tabInfo);
|
570
613
|
tabInfo.selected = true;
|
571
614
|
this.requestUpdate();
|
572
615
|
}
|
@@ -579,6 +622,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
579
622
|
this.#setAriaControls();
|
580
623
|
}
|
581
624
|
|
625
|
+
// remove after d2l-tab/d2l-tab-panel backport
|
582
626
|
async _handlePanelTextChange(e) {
|
583
627
|
const tabInfo = this._getTabInfo(e.target.id);
|
584
628
|
// event could be from nested tabs
|
@@ -757,8 +801,13 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
757
801
|
}
|
758
802
|
|
759
803
|
_resetFocusables() {
|
760
|
-
|
761
|
-
|
804
|
+
if (this._defaultSlotBehavior) {
|
805
|
+
const selectedTab = this._tabInfos.find(ti => ti.selected);
|
806
|
+
if (selectedTab) this._setFocusableDefaultSlotBehavior(selectedTab);
|
807
|
+
} else {
|
808
|
+
const selectedTab = this._tabs.find(ti => ti.selected);
|
809
|
+
if (selectedTab) this._setFocusable(selectedTab);
|
810
|
+
}
|
762
811
|
this.requestUpdate();
|
763
812
|
}
|
764
813
|
|
@@ -783,7 +832,15 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))
|
|
783
832
|
});
|
784
833
|
}
|
785
834
|
|
786
|
-
_setFocusable(
|
835
|
+
_setFocusable(tab) {
|
836
|
+
const currentFocusable = this._tabs.find(tab => tab.tabIndex === 0);
|
837
|
+
if (currentFocusable) currentFocusable.tabIndex = -1;
|
838
|
+
|
839
|
+
tab.tabIndex = 0;
|
840
|
+
}
|
841
|
+
|
842
|
+
// remove after d2l-tab/d2l-tab-panel backport
|
843
|
+
_setFocusableDefaultSlotBehavior(tabInfo) {
|
787
844
|
const currentFocusable = this._tabInfos.find(ti => ti.activeFocusable);
|
788
845
|
if (currentFocusable) currentFocusable.activeFocusable = false;
|
789
846
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.94.
|
3
|
+
"version": "3.94.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",
|