All Projects → github → combobox-nav

github / combobox-nav

Licence: MIT license
Attach combobox navigation behavior to <input> or <textarea>.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to combobox-nav

Downshift
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
Stars: ✭ 10,183 (+13298.68%)
Mutual labels:  autocomplete, combobox
choc-autocomplete
🏇 Autocomplete Component Package for Chakra UI
Stars: ✭ 286 (+276.32%)
Mutual labels:  autocomplete, combobox
Clojurevscode
Clojure support for Visual Studio Code
Stars: ✭ 204 (+168.42%)
Mutual labels:  autocomplete
S2s
Coding time Compile. A tool to write code fastest.
Stars: ✭ 254 (+234.21%)
Mutual labels:  autocomplete
Massautocomplete
Auto Complete for Angularjs applications with a lot to complete
Stars: ✭ 231 (+203.95%)
Mutual labels:  autocomplete
Heyui
🎉UI Toolkit for Web, Vue2.0 http://www.heyui.top
Stars: ✭ 2,373 (+3022.37%)
Mutual labels:  autocomplete
Autocomplete
Blazing fast and lightweight autocomplete widget without dependencies. Only 1KB gzipped. Demo:
Stars: ✭ 244 (+221.05%)
Mutual labels:  autocomplete
Snippets
Atom snippets package
Stars: ✭ 191 (+151.32%)
Mutual labels:  autocomplete
svelte-mapbox
MapBox Map and Autocomplete components for Svelte (or Vanilla JS)
Stars: ✭ 267 (+251.32%)
Mutual labels:  autocomplete
Vue2 Autocomplete
Vue 2 Component to make Autocomplete element.
Stars: ✭ 227 (+198.68%)
Mutual labels:  autocomplete
Inquirer Autocomplete Prompt
Autocomplete prompt for inquirer
Stars: ✭ 250 (+228.95%)
Mutual labels:  autocomplete
Lua Lsp
A Lua language server
Stars: ✭ 219 (+188.16%)
Mutual labels:  autocomplete
Punchkeyboard
Punchkeyboard is an open-source keyboard for virtual reality, enhanced with autocomplete and next word prediction functionality for a swift typing experience.
Stars: ✭ 208 (+173.68%)
Mutual labels:  autocomplete
Academic Phrases
Bypass that mental block when writing your papers.
Stars: ✭ 244 (+221.05%)
Mutual labels:  autocomplete
Company Sourcekit
Completion for Swift projects via SourceKit with the help of SourceKitten
Stars: ✭ 203 (+167.11%)
Mutual labels:  autocomplete
zsh-yarn-completions
Yarn completions for Z-shell that supports yarn workspaces
Stars: ✭ 35 (-53.95%)
Mutual labels:  autocomplete
Vue Cool Select
Select with autocomplete, slots, bootstrap and material design themes.
Stars: ✭ 195 (+156.58%)
Mutual labels:  autocomplete
Intelephense
Intellisense for PHP
Stars: ✭ 212 (+178.95%)
Mutual labels:  autocomplete
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+3559.21%)
Mutual labels:  autocomplete
oh-my-design-patterns
🎨 Record the articles and code I wrote while learning design patterns
Stars: ✭ 33 (-56.58%)
Mutual labels:  decorator

Combobox Navigation

Attach combobox navigation behavior (ARIA 1.2) to <input>.

Installation

$ npm install @github/combobox-nav

Usage

HTML

<label>
  Robot
  <input id="robot-input" type="text" />
</label>
<ul role="listbox" id="list-id" hidden>
  <li id="baymax" role="option">Baymax</li>
  <li><del>BB-8</del></li>
  <!-- `role=option` needs to be present for item to be selectable -->
  <li id="hubot" role="option">Hubot</li>
  <li id="r2-d2" role="option">R2-D2</li>
</ul>

Markup requirements:

  • Each option needs to have role="option" and a unique id
  • The list should have role="listbox"

JS

import Combobox from '@github/combobox-nav'
const input = document.querySelector('#robot-input')
const list = document.querySelector('#list-id')

// install combobox pattern on a given input and listbox
const combobox = new Combobox(input, list)
// when options appear, start intercepting keyboard events for navigation
combobox.start()
// when options disappear, stop intercepting keyboard events for navigation
combobox.stop()

// move selection to the nth+1 item in the list
combobox.navigate(1)
// reset selection
combobox.clearSelection()
// uninstall combobox pattern from the input
combobox.destroy()

Events

A bubbling combobox-commit event is fired on the list element when an option is selected via keyboard or click.

For example, autocomplete when an option is selected:

list.addEventListener('combobox-commit', function (event) {
  console.log('Element selected: ', event.target)
})

Note When using <label> + <input> as options, please listen on change instead of combobox-commit.

When a label is clicked on, click event is fired from both <label> and its associated input label.control. Since combobox does not know about the control, combobox-commit cannot be used as an indicator of the item's selection state.

Settings

For advanced configuration, the constructor takes an optional third argument. For example:

const combobox = new Combobox(input, list, {tabInsertsSuggestions: true})

These settings are available:

  • tabInsertsSuggestions: boolean = true - Control whether the highlighted suggestion is inserted when Tab is pressed (Enter will always insert a suggestion regardless of this setting). When true, tab-navigation will be hijacked when open (which can have negative impacts on accessibility) but the combobox will more closely imitate a native IDE experience.
  • defaultFirstOption: boolean = false - If no options are selected and the user presses Enter, should the first item be inserted? If enabled, the default option can be selected and styled with [data-combobox-option-default] . This should be styled differently from the aria-selected option.

    Warning Screen readers will not announce that the first item is the default. This should be announced explicitly with the use of aria-live status text.

Development

npm install
npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].