Merge "Fix searching in "included in"" into stable-3.1

This commit is contained in:
Paladox none
2020-06-10 16:10:53 +00:00
committed by Gerrit Code Review
3 changed files with 26 additions and 13 deletions

View File

@@ -78,13 +78,15 @@ limitations under the License.
on-click="_handleCloseTap">Close</gr-button>
</span>
<iron-input
placeholder="Filter"
on-bind-value-changed="_onFilterChanged">
id="filterInput"
placeholder="Filter"
bind-value="{{_filterText}}"
>
<input
id="filterInput"
is="iron-input"
placeholder="Filter"
on-bind-value-changed="_onFilterChanged">
is="iron-input"
placeholder="Filter"
bind-value="{{_filterText}}"
/>
</iron-input>
</header>
<div class$="[[_computeLoadingClass(_loaded)]]">Loading...</div>

View File

@@ -65,7 +65,9 @@
},
_computeGroups(includedIn, filterText) {
if (!includedIn) { return []; }
if (!includedIn || filterText === undefined) {
return [];
}
const filter = item => !filterText.length ||
item.toLowerCase().indexOf(filterText.toLowerCase()) !== -1;
@@ -94,11 +96,5 @@
_computeLoadingClass(loaded) {
return loaded ? 'loading loaded' : 'loading';
},
_onFilterChanged() {
this.debounce('filter-change', () => {
this._filterText = this.$.filterInput.bindValue;
}, 100);
},
});
})();

View File

@@ -82,5 +82,20 @@ limitations under the License.
{title: 'Tags', items: ['v2.0', 'v2.1']},
]);
});
test('_computeGroups with .bindValue', done => {
element.$.filterInput.bindValue = 'stable-3.2';
const includedIn = {branches: [], tags: []};
includedIn.branches.push('master', 'stable-3.2');
setTimeout(() => {
const filterText = element._filterText;
assert.deepEqual(element._computeGroups(includedIn, filterText), [
{title: 'Branches', items: ['stable-3.2']},
]);
done();
});
});
});
</script>