Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-01 12:10:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-01 12:10:28 +0300
commita928c5170fa58e4aef91ebca6c4fc9ec7cea812e (patch)
treedc700a0e00f32ea0aa8f642b75b7da7c24ade7e8 /app/assets/javascripts/ref
parent0a6b0190477aec55a1cff8e2812b177ea6df39b2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/ref')
-rw-r--r--app/assets/javascripts/ref/components/ref_selector.vue18
1 files changed, 16 insertions, 2 deletions
diff --git a/app/assets/javascripts/ref/components/ref_selector.vue b/app/assets/javascripts/ref/components/ref_selector.vue
index e388604ed92..dd84246159b 100644
--- a/app/assets/javascripts/ref/components/ref_selector.vue
+++ b/app/assets/javascripts/ref/components/ref_selector.vue
@@ -87,6 +87,15 @@ export default {
},
},
created() {
+ // This method is defined here instead of in `methods`
+ // because we need to access the .cancel() method
+ // lodash attaches to the function, which is
+ // made inaccessible by Vue. More info:
+ // https://stackoverflow.com/a/52988020/1063392
+ this.debouncedSearch = debounce(function search() {
+ this.search(this.query);
+ }, SEARCH_DEBOUNCE_MS);
+
this.setProjectId(this.projectId);
this.search(this.query);
},
@@ -95,9 +104,13 @@ export default {
focusSearchBox() {
this.$refs.searchBox.$el.querySelector('input').focus();
},
- onSearchBoxInput: debounce(function search() {
+ onSearchBoxEnter() {
+ this.debouncedSearch.cancel();
this.search(this.query);
- }, SEARCH_DEBOUNCE_MS),
+ },
+ onSearchBoxInput() {
+ this.debouncedSearch();
+ },
selectRef(ref) {
this.setSelectedRef(ref);
this.$emit('input', this.selectedRef);
@@ -129,6 +142,7 @@ export default {
class="gl-m-3"
:placeholder="i18n.searchPlaceholder"
@input="onSearchBoxInput"
+ @keydown.enter.prevent="onSearchBoxEnter"
/>
<div class="gl-flex-grow-1 gl-overflow-y-auto">