@brightspace-ui/core 3.123.0 → 3.123.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.
@@ -7,6 +7,7 @@ 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
9
  import { ifDefined } from 'lit/directives/if-defined.js';
10
+ import { isComposedAncestor } from '../../helpers/dom.js';
10
11
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
11
12
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
12
13
 
@@ -84,6 +85,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
84
85
  * @type {boolean}
85
86
  */
86
87
  noSticky: { attribute: 'no-sticky', type: Boolean },
88
+ _clicked: { state: true },
87
89
  _focused: { state: true },
88
90
  _hasBefore: { state: true },
89
91
  _hasSummary: { state: true },
@@ -321,6 +323,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
321
323
  this.paddingType = 'default';
322
324
  this.type = 'default';
323
325
  this.noSticky = false;
326
+ this._clicked = false;
324
327
  this._focused = false;
325
328
  this._group = undefined;
326
329
  this._groupSubscription = new EventSubscriberController(this, 'collapsible-panel-group', {
@@ -346,7 +349,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
346
349
  render() {
347
350
  const classes = {
348
351
  'd2l-collapsible-panel': true,
349
- 'focused': this._focused,
352
+ 'focused': this._focused && !this._clicked,
350
353
  'has-summary': this._hasSummary,
351
354
  'has-before': this._hasBefore,
352
355
  'scrolled': this._scrolled,
@@ -414,13 +417,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
414
417
  ));
415
418
  }
416
419
 
417
- _handleHeaderClick(e) {
418
- if (this.expanded) {
419
- this._toggleExpand();
420
- e.stopPropagation();
421
- }
422
- }
423
-
424
420
  _handleHeaderSecondaryClick(e) {
425
421
  const header = this.shadowRoot.querySelector('.d2l-collapsible-panel-header-secondary');
426
422
  if (e.target !== header) {
@@ -429,10 +425,9 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
429
425
  }
430
426
 
431
427
  _handlePanelClick(e) {
432
- if (!this.expanded) {
433
- this._toggleExpand();
434
- e.stopPropagation();
435
- }
428
+ this._clicked = e.detail && e.detail > 0; // detect if click event is from a mouse
429
+ const content = this.shadowRoot.querySelector('.d2l-collapsible-panel-content');
430
+ if (e.target !== content && !isComposedAncestor(content, e.target)) this._toggleExpand();
436
431
  }
437
432
 
438
433
  _handleSummarySlotChange(e) {
@@ -442,6 +437,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
442
437
 
443
438
  _onBlur() {
444
439
  this._focused = false;
440
+ this._clicked = false;
445
441
  }
446
442
 
447
443
  _onFocus() {
@@ -450,7 +446,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
450
446
 
451
447
  _renderHeader() {
452
448
  return html`
453
- <div class="d2l-collapsible-panel-header" @click="${this._handleHeaderClick}">
449
+ <div class="d2l-collapsible-panel-header">
454
450
  <div class="d2l-collapsible-panel-before">
455
451
  <slot name="before" @slotchange="${this._handleBeforeSlotChange}"></slot>
456
452
  </div>
@@ -488,7 +484,6 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
488
484
  class="d2l-collapsible-panel-opener"
489
485
  aria-expanded="${this.expanded}"
490
486
  type="button"
491
- @click="${this._handleHeaderClick}"
492
487
  @focus="${this._onFocus}"
493
488
  @blur="${this._onBlur}"
494
489
  aria-label="${ifDefined(this.expandCollapseLabel)}">${this.panelTitle}</button>
@@ -329,6 +329,36 @@
329
329
  </template>
330
330
  </d2l-demo-snippet>
331
331
 
332
+ <h2>Simple dialog with longer loading content</h2>
333
+
334
+ <d2l-demo-snippet>
335
+ <template>
336
+ <d2l-button>Show Dialog</d2l-button>
337
+ <d2l-dialog title-text="Fullscreen Title">
338
+ </d2l-dialog>
339
+ <d2l-dropdown style="display: none; padding: 30px;">
340
+ <button class="d2l-dropdown-opener">Open!</button>
341
+ <d2l-dropdown-content>
342
+ <a href=" " style="display: block;">A Link</a>
343
+ Some content... Click me!
344
+ </d2l-dropdown-content>
345
+ </d2l-dropdown>
346
+
347
+ <script>
348
+ (demo => {
349
+ demo.querySelector('d2l-button').addEventListener('click', () => {
350
+ demo.querySelector('d2l-dialog').opened = true;
351
+ setTimeout(() => {
352
+ demo.querySelector('d2l-dropdown').style.display = 'block';
353
+ demo.querySelector('d2l-dialog').appendChild(demo.querySelector('d2l-dropdown'));
354
+ demo.querySelector('d2l-dialog').resize();
355
+ }, 1000);
356
+ });
357
+ })(document.currentScript.parentNode);
358
+ </script>
359
+ </template>
360
+ </d2l-demo-snippet>
361
+
332
362
  </d2l-demo-page>
333
363
  </body>
334
364
  </html>
@@ -569,7 +569,8 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
569
569
  const activeElement = getComposedActiveElement();
570
570
 
571
571
  if (isComposedAncestor(this, activeElement)
572
- || isComposedAncestor(this.__getOpener(), activeElement)) {
572
+ || isComposedAncestor(this.__getOpener(), activeElement)
573
+ || activeElement === this.__previousFocusableAncestor) {
573
574
  return;
574
575
  }
575
576
  this.close();
@@ -954,7 +954,9 @@ export const PopoverMixin = superclass => class extends superclass {
954
954
  }
955
955
 
956
956
  const activeElement = getComposedActiveElement();
957
- if (isComposedAncestor(this, activeElement) || isComposedAncestor(this._opener, activeElement)) {
957
+ if (isComposedAncestor(this, activeElement)
958
+ || isComposedAncestor(this._opener, activeElement)
959
+ || activeElement === this._previousFocusableAncestor) {
958
960
  return;
959
961
  }
960
962
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.123.0",
3
+ "version": "3.123.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",