Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,16 @@
<div id="custom-fetching-items-popup-feedback" class="sr-only"></div>
</auto-complete>
<button type="submit">Save</button>
</form>
</form>
<script>
window.fetch = () => Promise.resolve(new Response(robotsList));
window.fetch = (url) => {
const query = url.split('?q=')[1]
console.log(query)
Comment thread
kendallgassner marked this conversation as resolved.
Outdated
if (query === 'none') {
return Promise.resolve(new Response('<li role="none" data-no-result-found="true">No results found!</li>'))
Comment thread
kendallgassner marked this conversation as resolved.
Outdated
}
return Promise.resolve(new Response(robotsList));
}
// fetchResult must be a function that return a Promise of string and that accepts as parameters an element and an URL
document.querySelector("auto-complete#custom-fetching-method").fetchResult = async (el, url) => (await fetch(url)).text();
</script>
Expand All @@ -119,7 +126,8 @@
<button type="submit">Save</button>
</form>

<!-- <script type="module" src="./dist/bundle.js"></script>-->
<!-- <script type="module" src="./dist/bundle.js"></script>-->
Comment thread
kendallgassner marked this conversation as resolved.
Outdated
<script type="module" src="https://unpkg.com/@github/auto-complete-element@latest/dist/bundle.js"></script>
</body>
</html>

4 changes: 3 additions & 1 deletion src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export default class Autocomplete {
this.identifyOptions()
this.combobox.indicateDefaultOption()
const allNewOptions = this.results.querySelectorAll('[role="option"]')
const hasResults = !!allNewOptions.length

const hasResults =
!!allNewOptions.length || !!this.results.querySelectorAll('[data-no-result-found="true"]').length
Comment thread
keithamus marked this conversation as resolved.
const numOptions = allNewOptions.length

const [firstOption] = allNewOptions
Expand Down