From 94177cee799eaf7c493b0fd1137d7eeaec4fd918 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Sat, 06 Jul 2019 00:10:00 +0000 Subject: [PATCH] Fix edge cases (no results, query empty) in find function --- map.js | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/map.js b/map.js index bd9765b..df297da 100644 --- a/map.js +++ b/map.js @@ -180,6 +180,11 @@ if(query === this.query) return; this.query = query; + if(query === '') { + deleteChildren(this.results); + return; + } + var features = []; stops_type.forEach(function(stop_type) { if(stop_type.substr(0,1) === 'p') return; @@ -344,7 +349,7 @@ if(vehicle_feature) { vehicles_source[prefix].removeFeature(vehicle_feature); if(feature_clicked && feature_clicked.getId() === vehicle_feature.getId()) { - featureClicked(); + panel.close(); } } continue; @@ -704,6 +709,11 @@ function listFeatures(features) { var div = document.createElement('div'); + if(features.length == 0) { + addParaWithText(div, lang.no_results); + return div; + } + addParaWithText(div, lang.select_feature); var feature, p, a, full_type, typeName; @@ -747,7 +757,6 @@ var feature = features[0]; if(features.length > 1) { - featureClicked(); panel.show(listFeatures(features)); return; } -- Gitblit v1.9.1