File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed
Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change 159159 <iron-icon icon="visibility" suffix></iron-icon>-->
160160 </ paper-input-autocomplete-chips >
161161 </ paper-material >
162+
163+
164+ < paper-material class ="demo-paper " style ="height: 300px; overflow: auto; ">
165+ < p > An example of < code > <paper-input-autocomplete-chips></ code > with the < code > noSuggestInactive</ code > attribute:</ p >
166+ < p > It won't suggest neither Alabama nor Alaska</ p >
167+ < paper-input-autocomplete-chips local-candidates ="{{states}} " label ="Chips " no-suggest-inactive >
168+ </ paper-input-autocomplete-chips >
169+ </ paper-material >
170+
162171
163172 < script >
164173 window . addEventListener ( 'WebComponentsReady' , function ( ) {
257266 text : "Alabama" ,
258267 imgUrl : 'https://lh5.googleusercontent.com/-tlQ1LE9IdgI/AAAAAAAAAAI/AAAAAAAAAAA/xTWfNFP8w_M/s32-c-mo/photo.jpg' ,
259268 tag : 'read-only' ,
260- readOnly : false
269+ readOnly : false ,
270+ inactive : true
261271 } ,
262272 {
263273 key : 2 ,
264274 text : "Alaska" ,
265- imgUrl : 'http://lorempixel.com/256/256/'
275+ imgUrl : 'http://lorempixel.com/256/256/' ,
276+ inactive : true
266277 } ,
267278 {
268279 key : 3 ,
Original file line number Diff line number Diff line change 123123 type : Boolean ,
124124 value : false
125125 } ,
126+
127+ /**
128+ * If set to true, candidate items which property 'inactive' are set to true
129+ * won't be suggested
130+ */
131+ noSuggestInactive : {
132+ type : Boolean ,
133+ value : false
134+ } ,
135+
126136 } ,
127137
128138 _tokenAcceptKeyCodesChanged : function ( newValue ) {
475485
476486 var patt = new RegExp ( this . _scapeString ( term . toLowerCase ( ) ) ) ;
477487 var matched = [ ] ;
478-
479- if ( this . localCandidates && this . localCandidates . length ) {
480- for ( var i = 0 ; i < this . localCandidates . length ; i ++ ) {
481- if ( patt . test ( this . localCandidates [ i ] . text . toLowerCase ( ) ) == true ) {
482- matched . push ( this . localCandidates [ i ] ) ;
488+ var candidates = this . localCandidates ;
489+
490+ if ( candidates && candidates . length ) {
491+ for ( var i = 0 ; i < candidates . length ; i ++ ) {
492+ var candidate = candidates [ i ] ;
493+ if ( Boolean ( this . noSuggestInactive ) && ! Boolean ( candidate . inactive ) ) {
494+ if ( patt . test ( candidate . text . toLowerCase ( ) ) == true ) {
495+ matched . push ( candidate ) ;
496+ }
483497 }
484498 }
485499 }
You can’t perform that action at this time.
0 commit comments