$airportSearch_fuzzySearch()

in src/frontend/src/shared/mixins/airportSearch.js [62:87]


    $airportSearch_fuzzySearch(value, update, abort) {
      // Min 3 chars for autocomplete
      if (value.length < 3) {
        abort()
        return
      }

      update(
        () => {
          // reset the list if search was cleared
          if (value === '') {
            this.airportSearch_suggestionList = airportList
          }

          let result = fuse.search(value.toLowerCase())
          this.airportSearch_suggestionList = result.map((i) => i.item)
        },
        // "ref" is the Vue reference to the QSelect
        (ref) => {
          if (value !== '' && ref.options.length > 0) {
            ref.setOptionIndex(-1) // reset optionIndex in case there is something selected
            ref.moveOptionSelection(1, true) // focus the first selectable option and do not update the input-value
          }
        }
      )
    }