summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-01-20 13:59:26 +0000
committerPhil Hughes <me@iamphill.com>2017-01-21 20:05:02 +0000
commit80c0b877d966226a8f31ea199c6cfc5cf4bf9527 (patch)
tree522600eee4119e5e2c8bcf125bdaa87be1718a2b /app
parenta4789db98e6ad39e8b890ebe93ee91bb4531eec3 (diff)
downloadgitlab-ce-80c0b877d966226a8f31ea199c6cfc5cf4bf9527.tar.gz
Fixed issue when label or milestone had space
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_utils.js.es617
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es64
2 files changed, 15 insertions, 6 deletions
diff --git a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
index 0027f79aecb..54792f987b0 100644
--- a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
+++ b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
@@ -83,14 +83,23 @@
return inputValue;
}
- return inputValue.slice(0, right + selectionStart + 1).trim();
+ return inputValue.slice(0, right + 1).trim();
}
static getInputSelectionPosition(input) {
- const inputValue = input.value;
+ let inputValue = input.value;
+ // Replace all spaces inside quote marks with underscores
+ // This helps with matching the beginning & end of a token:key
+ inputValue = inputValue.replace(/"(.*?)"/g, str => str.replace(/\s/g, '_') );
+
const selectionStart = input.selectionStart;
- let left = inputValue.slice(0, selectionStart + 1).search(/\S+$/);
- const right = inputValue.slice(selectionStart).search(/\s/);
+ let right = inputValue.slice(selectionStart).search(/\s/);
+
+ if (right >= 0) {
+ right += selectionStart;
+ }
+
+ let left = inputValue.slice(0, right).search(/\S+$/);
if (selectionStart === 0) {
left = 0;
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
index 9edb6ade4f2..cd0f41eb8ef 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
@@ -69,7 +69,7 @@
right = inputValue.length;
}
- input.value = `${inputValue.substr(0, left)}${word}${inputValue.substr(right + selectionStart)}`;
+ input.value = `${inputValue.substr(0, left)}${word}${inputValue.substr(right)}`;
gl.FilteredSearchDropdownManager.updateInputCaretPosition(selectionStart, input);
}
@@ -85,7 +85,7 @@
right = inputValue.length;
}
- input.setSelectionRange(selectionStart + right, selectionStart + right);
+ input.setSelectionRange(selectionStart + right, selectionStart);
}
updateCurrentDropdownOffset() {