@brightspace-ui/core 3.9.1 → 3.9.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.
@@ -285,6 +285,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
285
285
|
this._verticalOffset = defaultVerticalOffset;
|
286
286
|
|
287
287
|
this.__reposition = this.__reposition.bind(this);
|
288
|
+
this.__onAncestorMutation = this.__onAncestorMutation.bind(this);
|
288
289
|
this.__onResize = this.__onResize.bind(this);
|
289
290
|
this.__onAutoCloseFocus = this.__onAutoCloseFocus.bind(this);
|
290
291
|
this.__onAutoCloseClick = this.__onAutoCloseClick.bind(this);
|
@@ -458,10 +459,16 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
458
459
|
return (value === 'scroll' || value === 'auto');
|
459
460
|
};
|
460
461
|
|
461
|
-
let node = this;
|
462
462
|
this.__removeRepositionHandlers();
|
463
|
+
|
464
|
+
this._ancestorMutationObserver ??= new MutationObserver(this.__onAncestorMutation);
|
465
|
+
const mutationConfig = { attributes: true, childList: true, subtree: true };
|
466
|
+
|
467
|
+
let node = this;
|
463
468
|
this._scrollablesObserved = [];
|
464
469
|
while (node) {
|
470
|
+
|
471
|
+
// observe scrollables
|
465
472
|
let observeScrollable = false;
|
466
473
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
467
474
|
observeScrollable = isScrollable(node, 'overflow-y') || isScrollable(node, 'overflow-x');
|
@@ -472,6 +479,12 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
472
479
|
this._scrollablesObserved.push(node);
|
473
480
|
node.addEventListener('scroll', this.__reposition);
|
474
481
|
}
|
482
|
+
|
483
|
+
// observe mutations on each DOM scope (excludes sibling scopes... can only do so much)
|
484
|
+
if (node.nodeType === Node.DOCUMENT_NODE || (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && node.host)) {
|
485
|
+
this._ancestorMutationObserver.observe(node, mutationConfig);
|
486
|
+
}
|
487
|
+
|
475
488
|
node = getComposedParent(node);
|
476
489
|
}
|
477
490
|
|
@@ -528,6 +541,13 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
528
541
|
this._hasHeader = e.target.assignedNodes().length !== 0;
|
529
542
|
}
|
530
543
|
|
544
|
+
__onAncestorMutation(mutations) {
|
545
|
+
const opener = this.__getOpener();
|
546
|
+
// ignore mutations that are within this dropdown
|
547
|
+
const reposition = !!mutations.find(mutation => !isComposedAncestor(opener, mutation.target));
|
548
|
+
if (reposition) this.__reposition();
|
549
|
+
}
|
550
|
+
|
531
551
|
__onAutoCloseClick(e) {
|
532
552
|
if (!this.opened || this.noAutoClose) {
|
533
553
|
return;
|
@@ -791,12 +811,13 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
|
|
791
811
|
|
792
812
|
__removeRepositionHandlers() {
|
793
813
|
if (!this._fixedPositioning) return;
|
794
|
-
if (!this._scrollablesObserved) return;
|
795
814
|
|
796
|
-
this._scrollablesObserved
|
815
|
+
this._scrollablesObserved?.forEach(node => {
|
797
816
|
node.removeEventListener('scroll', this.__reposition);
|
798
817
|
});
|
799
818
|
this._scrollablesObserved = null;
|
819
|
+
|
820
|
+
this._ancestorMutationObserver?.disconnect();
|
800
821
|
}
|
801
822
|
|
802
823
|
__reposition() {
|
@@ -137,7 +137,7 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
137
137
|
}
|
138
138
|
|
139
139
|
willUpdate(changedProperties) {
|
140
|
-
if (changedProperties.has('preferFixedPositioning')) {
|
140
|
+
if (this._fixedPositioning === undefined || changedProperties.has('preferFixedPositioning')) {
|
141
141
|
this._fixedPositioning = (window.D2L?.LP?.Web?.UI?.Flags.Flag('GAUD-131-dropdown-fixed-positioning', false) && this.preferFixedPositioning);
|
142
142
|
}
|
143
143
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.9.
|
3
|
+
"version": "3.9.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",
|