Skip to content

Commit 50dbb6c

Browse files
committed
[BUG] when no list element
1 parent 40e8ece commit 50dbb6c

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

dist/ol-ext.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5169,7 +5169,7 @@ ol.control.Search = class olcontrolSearch extends ol.control.Control {
51695169
self.dispatchEvent({ type: "change:input", input: e, value: input.value });
51705170
});
51715171
var doSearch = function (e) {
5172-
// console.log(e.type+" "+e.key)'
5172+
// console.log(e.type+" "+e.key)
51735173
var li = element.querySelector("ul.autocomplete li.select");
51745174
var val = input.value;
51755175
// move up/down
@@ -5183,8 +5183,10 @@ ol.control.Search = class olcontrolSearch extends ol.control.Control {
51835183
}
51845184
} else {
51855185
li = element.querySelector("ul.autocomplete li")
5186-
li.classList.add("select");
5187-
input.value = li.innerText;
5186+
if (li) {
5187+
li.classList.add("select");
5188+
input.value = li.innerText;
5189+
}
51885190
}
51895191
}
51905192
// Clear input
@@ -5215,20 +5217,22 @@ ol.control.Search = class olcontrolSearch extends ol.control.Control {
52155217
cur = val;
52165218
if (cur) {
52175219
// prevent searching on each typing
5218-
if (tout)
5220+
if (tout) {
52195221
clearTimeout(tout);
5222+
}
52205223
var minLength = self.get("minLength");
52215224
tout = setTimeout(function () {
52225225
if (cur.length >= minLength) {
52235226
var s = self.autocomplete(cur, function (auto) { self.drawList_(auto); });
5224-
if (s)
5227+
if (s) {
52255228
self.drawList_(s);
5226-
}
5227-
else
5229+
}
5230+
} else {
52285231
self.drawList_();
5232+
}
52295233
}, options.typing);
52305234
} else {
5231-
self.drawList_();
5235+
self.drawList_();
52325236
}
52335237
}
52345238
// Clear list selection

dist/ol-ext.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/control/Search.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var ol_control_Search = class olcontrolSearch extends ol_control_Control {
9999
self.dispatchEvent({ type: "change:input", input: e, value: input.value });
100100
});
101101
var doSearch = function (e) {
102-
// console.log(e.type+" "+e.key)'
102+
// console.log(e.type+" "+e.key)
103103
var li = element.querySelector("ul.autocomplete li.select");
104104
var val = input.value;
105105
// move up/down
@@ -113,8 +113,10 @@ var ol_control_Search = class olcontrolSearch extends ol_control_Control {
113113
}
114114
} else {
115115
li = element.querySelector("ul.autocomplete li")
116-
li.classList.add("select");
117-
input.value = li.innerText;
116+
if (li) {
117+
li.classList.add("select");
118+
input.value = li.innerText;
119+
}
118120
}
119121
}
120122

@@ -148,20 +150,22 @@ var ol_control_Search = class olcontrolSearch extends ol_control_Control {
148150
cur = val;
149151
if (cur) {
150152
// prevent searching on each typing
151-
if (tout)
153+
if (tout) {
152154
clearTimeout(tout);
155+
}
153156
var minLength = self.get("minLength");
154157
tout = setTimeout(function () {
155158
if (cur.length >= minLength) {
156159
var s = self.autocomplete(cur, function (auto) { self.drawList_(auto); });
157-
if (s)
160+
if (s) {
158161
self.drawList_(s);
159-
}
160-
else
162+
}
163+
} else {
161164
self.drawList_();
165+
}
162166
}, options.typing);
163167
} else {
164-
self.drawList_();
168+
self.drawList_();
165169
}
166170
}
167171

0 commit comments

Comments
 (0)