@nectary/components 1.2.0 → 1.2.1
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/package.json +1 -1
- package/pop/index.js +21 -10
package/package.json
CHANGED
package/pop/index.js
CHANGED
|
@@ -13,7 +13,7 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
13
13
|
#$contentSlot;
|
|
14
14
|
#$targetOpenWrapper;
|
|
15
15
|
#targetActiveElement = null;
|
|
16
|
-
#controller
|
|
16
|
+
#controller;
|
|
17
17
|
#keydownContext;
|
|
18
18
|
#visibilityContext;
|
|
19
19
|
#targetStyleValue = null;
|
|
@@ -31,10 +31,13 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
31
31
|
this.#resizeThrottle = throttleAnimationFrame(this.#updateOrientation);
|
|
32
32
|
this.#keydownContext = new Context(this.#$contentSlot, 'keydown');
|
|
33
33
|
this.#visibilityContext = new Context(this.#$contentSlot, 'visibility');
|
|
34
|
+
this.#controller = new AbortController();
|
|
34
35
|
}
|
|
35
36
|
connectedCallback() {
|
|
36
37
|
super.connectedCallback();
|
|
37
|
-
this.#controller
|
|
38
|
+
if (this.#controller === null) {
|
|
39
|
+
this.#controller = new AbortController();
|
|
40
|
+
}
|
|
38
41
|
const {
|
|
39
42
|
signal
|
|
40
43
|
} = this.#controller;
|
|
@@ -58,6 +61,8 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
58
61
|
disconnectedCallback() {
|
|
59
62
|
super.disconnectedCallback();
|
|
60
63
|
this.#controller.abort();
|
|
64
|
+
this.#controller = null;
|
|
65
|
+
this.#resizeThrottle.cancel();
|
|
61
66
|
this.#onCollapse();
|
|
62
67
|
}
|
|
63
68
|
static get observedAttributes() {
|
|
@@ -102,7 +107,9 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
102
107
|
{
|
|
103
108
|
if (isAttrTrue(newVal)) {
|
|
104
109
|
requestAnimationFrame(() => {
|
|
105
|
-
this
|
|
110
|
+
if (this.isConnected && getBooleanAttribute(this, 'open')) {
|
|
111
|
+
this.#onExpand();
|
|
112
|
+
}
|
|
106
113
|
});
|
|
107
114
|
} else {
|
|
108
115
|
this.#onCollapse();
|
|
@@ -186,9 +193,11 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
186
193
|
this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
|
|
187
194
|
if (!isElementFocused(this.#targetActiveElement)) {
|
|
188
195
|
requestAnimationFrame(() => {
|
|
189
|
-
this
|
|
190
|
-
|
|
191
|
-
|
|
196
|
+
if (this.isConnected && this.#isOpen()) {
|
|
197
|
+
this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
|
|
198
|
+
this.#targetActiveElement.focus();
|
|
199
|
+
this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
|
|
200
|
+
}
|
|
192
201
|
});
|
|
193
202
|
}
|
|
194
203
|
}
|
|
@@ -196,7 +205,7 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
196
205
|
disableScroll();
|
|
197
206
|
window.addEventListener('resize', this.#onResize);
|
|
198
207
|
requestAnimationFrame(() => {
|
|
199
|
-
if (this.#isOpen()) {
|
|
208
|
+
if (this.isConnected && this.#isOpen()) {
|
|
200
209
|
this.#$contentSlot.addEventListener('slotchange', this.#onContentSlotChange);
|
|
201
210
|
}
|
|
202
211
|
});
|
|
@@ -238,9 +247,11 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
238
247
|
if (!isElementFocused(this.#targetActiveElement)) {
|
|
239
248
|
const $targetEl = this.#targetActiveElement;
|
|
240
249
|
requestAnimationFrame(() => {
|
|
241
|
-
this
|
|
242
|
-
|
|
243
|
-
|
|
250
|
+
if (this.isConnected && !this.#isOpen()) {
|
|
251
|
+
this.#$targetSlot.addEventListener('focus', this.#stopEventPropagation, true);
|
|
252
|
+
$targetEl.focus();
|
|
253
|
+
this.#$targetSlot.removeEventListener('focus', this.#stopEventPropagation, true);
|
|
254
|
+
}
|
|
244
255
|
});
|
|
245
256
|
}
|
|
246
257
|
this.#targetActiveElement = null;
|