@brightspace-ui/core 3.127.1 → 3.127.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.
@@ -6,6 +6,7 @@ import { heading1Styles, heading2Styles, heading3Styles, heading4Styles } from '
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js';
|
7
7
|
import { EventSubscriberController } from '../../controllers/subscriber/subscriberControllers.js';
|
8
8
|
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
|
9
|
+
import { getComposedActiveElement } from '../../helpers/focus.js';
|
9
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
10
11
|
import { isComposedAncestor } from '../../helpers/dom.js';
|
11
12
|
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
@@ -27,6 +28,21 @@ const normalizeHeadingLevel = (number) => {
|
|
27
28
|
|
28
29
|
const defaultHeading = 3;
|
29
30
|
|
31
|
+
let tabPressed = false;
|
32
|
+
let tabListenerAdded = false;
|
33
|
+
function addTabListener() {
|
34
|
+
if (tabListenerAdded) return;
|
35
|
+
tabListenerAdded = true;
|
36
|
+
document.addEventListener('keydown', e => {
|
37
|
+
if (e.keyCode !== 9) return;
|
38
|
+
tabPressed = true;
|
39
|
+
});
|
40
|
+
document.addEventListener('keyup', e => {
|
41
|
+
if (e.keyCode !== 9) return;
|
42
|
+
tabPressed = false;
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
30
46
|
/**
|
31
47
|
* A container with a title that can be expanded/collapsed to show/hide content.
|
32
48
|
* @slot before - Slot for content to be placed at the left side of the header, aligned with the title and header slot
|
@@ -85,7 +101,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
|
|
85
101
|
* @type {boolean}
|
86
102
|
*/
|
87
103
|
noSticky: { attribute: 'no-sticky', type: Boolean },
|
88
|
-
_clicked: { state: true },
|
89
104
|
_focused: { state: true },
|
90
105
|
_hasBefore: { state: true },
|
91
106
|
_hasSummary: { state: true },
|
@@ -323,7 +338,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
|
|
323
338
|
this.paddingType = 'default';
|
324
339
|
this.type = 'default';
|
325
340
|
this.noSticky = false;
|
326
|
-
this._clicked = false;
|
327
341
|
this._focused = false;
|
328
342
|
this._group = undefined;
|
329
343
|
this._groupSubscription = new EventSubscriberController(this, 'collapsible-panel-group', {
|
@@ -341,6 +355,11 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
|
|
341
355
|
return '.d2l-collapsible-panel-opener';
|
342
356
|
}
|
343
357
|
|
358
|
+
connectedCallback() {
|
359
|
+
super.connectedCallback();
|
360
|
+
addTabListener();
|
361
|
+
}
|
362
|
+
|
344
363
|
disconnectedCallback() {
|
345
364
|
super.disconnectedCallback();
|
346
365
|
if (this._intersectionObserver) this._intersectionObserver.disconnect();
|
@@ -349,7 +368,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
|
|
349
368
|
render() {
|
350
369
|
const classes = {
|
351
370
|
'd2l-collapsible-panel': true,
|
352
|
-
'focused': this._focused
|
371
|
+
'focused': this._focused,
|
353
372
|
'has-summary': this._hasSummary,
|
354
373
|
'has-before': this._hasBefore,
|
355
374
|
'scrolled': this._scrolled,
|
@@ -425,7 +444,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
|
|
425
444
|
}
|
426
445
|
|
427
446
|
_handlePanelClick(e) {
|
428
|
-
this._clicked = e.detail && e.detail > 0; // detect if click event is from a mouse
|
429
447
|
const content = this.shadowRoot.querySelector('.d2l-collapsible-panel-content');
|
430
448
|
if (e.target !== content && !isComposedAncestor(content, e.target)) this._toggleExpand();
|
431
449
|
}
|
@@ -436,11 +454,15 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
|
|
436
454
|
}
|
437
455
|
|
438
456
|
_onBlur() {
|
439
|
-
|
440
|
-
|
457
|
+
setTimeout(() => {
|
458
|
+
// don't remove focus if the button still ends up in focus
|
459
|
+
if (getComposedActiveElement() === this.shadowRoot.querySelector('button')) return;
|
460
|
+
this._focused = false;
|
461
|
+
}, 10);
|
441
462
|
}
|
442
463
|
|
443
464
|
_onFocus() {
|
465
|
+
if (!tabPressed) return;
|
444
466
|
this._focused = true;
|
445
467
|
}
|
446
468
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.127.
|
3
|
+
"version": "3.127.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",
|