summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/filtered_search
diff options
context:
space:
mode:
authorFilipa Lacerda <lacerda.filipa@gmail.com>2017-01-27 21:40:38 +0000
committerFilipa Lacerda <lacerda.filipa@gmail.com>2017-01-27 21:40:38 +0000
commitd2a2ba9381b3f3e11760434a2f963090ae071284 (patch)
tree203497ecbc39e0554e91a52d4f5fcae87348636f /app/assets/javascripts/filtered_search
parent763d7ad2d99770873a76869987726bff2d703869 (diff)
parent42836e8ef8ed6bf4b6748f6a9dc37d9173751bd1 (diff)
downloadgitlab-ce-d2a2ba9381b3f3e11760434a2f963090ae071284.tar.gz
Merge branch '27248-filtered-search-does-not-allow-filtering-labels-with-multiple-words' into 'master'
Fix filtering label and milestone with multiple words Closes #27248 and #27334 See merge request !8830
Diffstat (limited to 'app/assets/javascripts/filtered_search')
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_utils.js.es610
1 files changed, 8 insertions, 2 deletions
diff --git a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
index eeab10fba17..de3fa116717 100644
--- a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
+++ b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
@@ -28,7 +28,12 @@
if (lastToken !== searchToken) {
const title = updatedItem.title.toLowerCase();
let value = lastToken.value.toLowerCase();
- value = value.replace(/"(.*?)"/g, str => str.slice(1).slice(0, -1));
+
+ // Removes the first character if it is a quotation so that we can search
+ // with multiple words
+ if ((value[0] === '"' || value[0] === '\'') && title.indexOf(' ') !== -1) {
+ value = value.slice(1);
+ }
// Eg. filterSymbol = ~ for labels
const matchWithoutSymbol = lastToken.symbol === filterSymbol && title.indexOf(value) !== -1;
@@ -83,8 +88,9 @@
const selectionStart = input.selectionStart;
let inputValue = input.value;
// Replace all spaces inside quote marks with underscores
+ // (will continue to match entire string until an end quote is found if any)
// This helps with matching the beginning & end of a token:key
- inputValue = inputValue.replace(/("(.*?)"|:\s+)/g, str => str.replace(/\s/g, '_'));
+ inputValue = inputValue.replace(/(('[^']*'{0,1})|("[^"]*"{0,1})|:\s+)/g, str => str.replace(/\s/g, '_'));
// Get the right position for the word selected
// Regex matches first space