File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 100100 < div id ="custom-fetching-items-popup-feedback " class ="sr-only "> </ div >
101101 </ auto-complete >
102102 < button type ="submit "> Save</ button >
103- </ form >
103+ </ form >
104104 < script >
105- window . fetch = ( ) => Promise . resolve ( new Response ( robotsList ) ) ;
105+ window . fetch = ( url ) => {
106+ const query = url . split ( '?q=' ) [ 1 ]
107+ console . log ( query )
108+ if ( query === 'none' ) {
109+ return Promise . resolve ( new Response ( '<li role="none" data-no-result-found="true">No results found!</li>' ) )
110+ }
111+ return Promise . resolve ( new Response ( robotsList ) ) ;
112+ }
106113 // fetchResult must be a function that return a Promise of string and that accepts as parameters an element and an URL
107114 document . querySelector ( "auto-complete#custom-fetching-method" ) . fetchResult = async ( el , url ) => ( await fetch ( url ) ) . text ( ) ;
108115 </ script >
119126 < button type ="submit "> Save</ button >
120127 </ form >
121128
122- <!-- <script type="module" src="./dist/bundle.js"></script>-- >
123- < script type ="module " src ="https://unpkg.com/@github/auto-complete-element@latest/dist/bundle.js "> </ script >
129+ < script type ="module " src ="./dist/bundle.js "> </ script >
130+ <!-- < script type="module" src="https://unpkg.com/@github/auto-complete-element@latest/dist/bundle.js"></script> -- >
124131 </ body >
125132</ html >
133+
Original file line number Diff line number Diff line change @@ -209,7 +209,9 @@ export default class Autocomplete {
209209 this . identifyOptions ( )
210210 this . combobox . indicateDefaultOption ( )
211211 const allNewOptions = this . results . querySelectorAll ( '[role="option"]' )
212- const hasResults = ! ! allNewOptions . length
212+
213+ const hasResults =
214+ ! ! allNewOptions . length || ! ! this . results . querySelectorAll ( '[data-no-result-found="true"]' ) . length
213215 const numOptions = allNewOptions . length
214216
215217 const [ firstOption ] = allNewOptions
You can’t perform that action at this time.
0 commit comments