Sha256: 1f22aa26cc6cd6bf8445d37d0e86321d78577c26533d76c8c9998ed67d41a88d

Contents?: true

Size: 914 Bytes

Versions: 11

Compression:

Stored size: 914 Bytes

Contents

import Combobox from "hw_combobox/models/combobox/base"
import { cancel } from "hw_combobox/helpers"

Combobox.Navigation = Base => class extends Base {
  navigate(event) {
    if (this._autocompletesList) {
      this._keyHandlers[event.key]?.call(this, event)
    }
  }

  _keyHandlers = {
    ArrowUp: (event) => {
      this._selectIndex(this._selectedOptionIndex - 1)
      cancel(event)
    },
    ArrowDown: (event) => {
      this._selectIndex(this._selectedOptionIndex + 1)
      cancel(event)
    },
    Home: (event) => {
      this._selectIndex(0)
      cancel(event)
    },
    End: (event) => {
      this._selectIndex(this._visibleOptionElements.length - 1)
      cancel(event)
    },
    Enter: (event) => {
      this.close()
      this._actingCombobox.blur()
      cancel(event)
    },
    Escape: (event) => {
      this.close()
      this._actingCombobox.blur()
      cancel(event)
    }
  }
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hotwire_combobox-0.1.43 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.42 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.41 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.40 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.39 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.38 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.37 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.36 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.35 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.34 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.1.33 app/assets/javascripts/hw_combobox/models/combobox/navigation.js