Sha256: b355067cd8b36f12670ae37952b9b3cd128dd89def9e9191c28e412d660d5049
Contents?: true
Size: 1.26 KB
Versions: 20
Compression:
Stored size: 1.26 KB
Contents
import Combobox from "models/combobox/base" import { startsWith } from "helpers" Combobox.Autocomplete = Base => class extends Base { _connectListAutocomplete() { if (!this._autocompletesList) { this._visuallyHideListbox() } } _maybeAutocompleteWith(option, { force }) { if (!this._autocompletesInline && !force) return const typedValue = this._actingCombobox.value const autocompletedValue = option.getAttribute(this.autocompletableAttributeValue) if (force) { this._actingCombobox.value = autocompletedValue this._actingCombobox.setSelectionRange(autocompletedValue.length, autocompletedValue.length) } else if (startsWith(autocompletedValue, typedValue)) { this._actingCombobox.value = autocompletedValue this._actingCombobox.setSelectionRange(typedValue.length, autocompletedValue.length) } } // +visuallyHideListbox+ hides the listbox from the user, // but makes it still searchable by JS. _visuallyHideListbox() { this.listboxTarget.style.display = "none" } get _autocompletesList() { return this.autocompleteValue === "both" || this.autocompleteValue === "list" } get _autocompletesInline() { return this.autocompleteValue === "both" || this.autocompleteValue === "inline" } }
Version data entries
20 entries across 20 versions & 1 rubygems