polaris_view_components 4.0.0 → 4.0.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2556310257a7b7bc5360830ea381c0619787796c347ba9414e7ff98826f6e19b
|
|
4
|
+
data.tar.gz: 3120e335bb52aca18bf9e7e5a00b773a47b02a74777bf3467204847604f7f2f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6e016aaaac91d443b9d9846b4d49748819a436ba43f7f9e4d2acfd4d3cf9435d54591a17c143b8f76f8d1d85257ff0387f19c69bd7db769d5419c6acaaa886a
|
|
7
|
+
data.tar.gz: f88419ccb82a51a2963ed40356c731ab279bbb5892585e27429cdd619ffb43115a6f04180ca6f00299bc026d4ecb424007ae8e1e691859909f6a3839b76b2595
|
|
@@ -44,6 +44,10 @@ export default class extends Controller {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
onInputChange = debounce(() => {
|
|
47
|
+
// The element may have been removed (e.g. replaced by a Turbo Stream)
|
|
48
|
+
// before the debounced callback fires.
|
|
49
|
+
if (!this.element.isConnected) return
|
|
50
|
+
|
|
47
51
|
if (this.isRemote) {
|
|
48
52
|
this.fetchResults()
|
|
49
53
|
} else {
|
|
@@ -80,6 +84,9 @@ export default class extends Controller {
|
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
handleResults() {
|
|
87
|
+
// The popover controller is gone once the element has been disconnected.
|
|
88
|
+
if (!this.popoverController) return
|
|
89
|
+
|
|
83
90
|
if (this.visibleOptions.length > 0) {
|
|
84
91
|
this.hideEmptyState()
|
|
85
92
|
this.popoverController.show()
|
|
@@ -119,6 +126,8 @@ export default class extends Controller {
|
|
|
119
126
|
if (response.ok) {
|
|
120
127
|
const results = await response.html
|
|
121
128
|
|
|
129
|
+
// Ignore responses that arrive after the element was removed from the page.
|
|
130
|
+
if (!this.element.isConnected) return
|
|
122
131
|
if (requestId !== this.latestRequestId || query !== this.value) return
|
|
123
132
|
|
|
124
133
|
this.resultsTarget.innerHTML = results
|
|
@@ -212,6 +212,7 @@ class Autocomplete extends Controller {
|
|
|
212
212
|
this.element.dispatchEvent(changeEvent);
|
|
213
213
|
}
|
|
214
214
|
onInputChange=debounce((() => {
|
|
215
|
+
if (!this.element.isConnected) return;
|
|
215
216
|
if (this.isRemote) {
|
|
216
217
|
this.fetchResults();
|
|
217
218
|
} else {
|
|
@@ -238,6 +239,7 @@ class Autocomplete extends Controller {
|
|
|
238
239
|
return [ ...this.optionTargets ].filter((option => !option.classList.contains("Polaris--hidden")));
|
|
239
240
|
}
|
|
240
241
|
handleResults() {
|
|
242
|
+
if (!this.popoverController) return;
|
|
241
243
|
if (this.visibleOptions.length > 0) {
|
|
242
244
|
this.hideEmptyState();
|
|
243
245
|
this.popoverController.show();
|
|
@@ -276,6 +278,7 @@ class Autocomplete extends Controller {
|
|
|
276
278
|
});
|
|
277
279
|
if (response.ok) {
|
|
278
280
|
const results = await response.html;
|
|
281
|
+
if (!this.element.isConnected) return;
|
|
279
282
|
if (requestId !== this.latestRequestId || query !== this.value) return;
|
|
280
283
|
this.resultsTarget.innerHTML = results;
|
|
281
284
|
this.handleResults();
|