summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js')
-rw-r--r--polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js51
1 files changed, 34 insertions, 17 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
index c0449bef68..2e55010ec2 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
@@ -1,16 +1,19 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/**
+ * @license
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
(function() {
'use strict';
@@ -46,6 +49,7 @@
},
suggestions: {
type: Array,
+ value: () => [],
observer: '_resetCursorStops',
},
_suggestionEls: {
@@ -55,8 +59,8 @@
},
behaviors: [
- Polymer.IronFitBehavior,
Gerrit.KeyboardShortcutBehavior,
+ Polymer.IronFitBehavior,
],
keyBindings: {
@@ -136,9 +140,14 @@
_handleTapItem(e) {
e.preventDefault();
e.stopPropagation();
+ let selected = e.target;
+ while (!selected.classList.contains('autocompleteOption')) {
+ if (!selected || selected === this) { return; }
+ selected = selected.parentElement;
+ }
this.fire('item-selected', {
trigger: 'tap',
- selected: e.target,
+ selected,
});
},
@@ -151,12 +160,20 @@
},
_resetCursorStops() {
- Polymer.dom.flush();
- this._suggestionEls = this.$.suggestions.querySelectorAll('li');
+ if (this.suggestions.length > 0) {
+ Polymer.dom.flush();
+ this._suggestionEls = this.$.suggestions.querySelectorAll('li');
+ } else {
+ this._suggestionEls = [];
+ }
},
_resetCursorIndex() {
this.$.cursor.setCursorAtIndex(0);
},
+
+ _computeLabelClass(item) {
+ return item.label ? '' : 'hide';
+ },
});
})();