@@ -21,19 +21,20 @@ class ComboBox {
2121 // Add options in the dropdown list
2222 const listbox = this . element . querySelector ( '[role="listbox"]' ) ;
2323 rows . forEach ( ( row , index ) => {
24+ const icon = row . icon ;
2425 const option = document . createElement ( 'div' ) ;
2526 option . setAttribute ( 'role' , 'option' ) ;
2627 option . setAttribute ( 'aria-selected' , 'false' ) ;
27- option . dataset . name = row ;
28+ option . dataset . name = row . technology ;
2829 option . dataset . key = index ;
29- option . textContent = row ;
30- option . id = `${ this . element . dataset . id } -${ row . replaceAll ( ' ' , '-' ) } ` ;
30+ option . textContent = row . technology ;
31+ option . id = `${ this . element . dataset . id } -${ row . technology . replaceAll ( ' ' , '-' ) } ` ;
3132 const logo = document . createElement ( 'img' ) ;
3233 logo . setAttribute ( 'alt' , '' ) ;
33- logo . setAttribute ( 'src' , `https://cdn.httparchive.org/static/icons/${ row } .png ` ) ;
34+ logo . setAttribute ( 'src' , `https://cdn.httparchive.org/static/icons/${ icon } ` ) ;
3435 logo . setAttribute ( 'loading' , 'lazy' ) ;
3536 option . append ( logo ) ;
36- if ( this . selected . includes ( row ) ) {
37+ if ( this . selected . includes ( row . technology ) ) {
3738 option . setAttribute ( 'aria-selected' , true ) ;
3839 }
3940 listbox . append ( option ) ;
@@ -83,7 +84,7 @@ class ComboBox {
8384 const options = this . element . querySelector ( '[role="listbox"]' ) ;
8485
8586 this . filteredData = this . data . filter ( row => {
86- return row . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ;
87+ return row . technology . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ;
8788 } ) ;
8889
8990 options . textContent = '' ;
@@ -186,6 +187,7 @@ class ComboBox {
186187 }
187188
188189 showSelectedElement ( name ) {
190+ const icon = this . data . find ( ( ( tech ) => tech . technology == name ) ) ?. icon ;
189191 /* Add selected element to an overview list */
190192 const selection = document . createElement ( 'li' ) ;
191193 selection . dataset . name = name ;
@@ -198,7 +200,7 @@ class ComboBox {
198200
199201 /* Add the app logo */
200202 const appIcon = document . createElement ( 'img' ) ;
201- appIcon . setAttribute ( 'src' , `https://cdn.httparchive.org/static/icons/${ encodeURI ( name ) } .png ` ) ;
203+ appIcon . setAttribute ( 'src' , `https://cdn.httparchive.org/static/icons/${ encodeURI ( icon ) } ` ) ;
202204 appIcon . setAttribute ( 'alt' , '' ) ;
203205 appIcon . classList . add ( 'logo' ) ;
204206 deleteSelection . append ( appIcon ) ;
0 commit comments