Fix searching in "included in"
* filterText can sometimes be undefined, so we remove the .length part as an empty string would still be false with '!'. * We move to using bindValue. Bug: Issue 12778 Change-Id: I498c61fff930af4cc4e2846f6da672b97a3d322a
This commit is contained in:
		@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    },
 | 
			
		||||
  });
 | 
			
		||||
})();
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user