Sha256: d98129856a9fb1b50761ef48611f03b700bb0b0e2360e9c8a4dcd504c7d72b25

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

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._navigationKeyHandlers[event.key]?.call(this, event)
    }
  }

  _navigationKeyHandlers = {
    ArrowUp: (event) => {
      this._selectIndex(this._selectedOptionIndex - 1)
      cancel(event)
    },
    ArrowDown: (event) => {
      this._selectIndex(this._selectedOptionIndex + 1)

      if (this._selectedOptionIndex === 0) {
        this._actingListbox.scrollTop = 0
      }

      cancel(event)
    },
    Home: (event) => {
      this._selectIndex(0)
      cancel(event)
    },
    End: (event) => {
      this._selectIndex(this._visibleOptionElements.length - 1)
      cancel(event)
    },
    Enter: (event) => {
      this._closeAndBlur("hw:keyHandler:enter")
      cancel(event)
    },
    Escape: (event) => {
      this._closeAndBlur("hw:keyHandler:escape")
      cancel(event)
    },
    Backspace: (event) => {
      if (this._isMultiselect && !this._fullQuery) {
        this._focusLastChipDismisser()
        cancel(event)
      }
    }
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hotwire_combobox-0.3.2 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.3.1 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.3.0 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.2.5 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.2.4 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.2.3 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.2.2 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.2.1 app/assets/javascripts/hw_combobox/models/combobox/navigation.js
hotwire_combobox-0.2.0 app/assets/javascripts/hw_combobox/models/combobox/navigation.js