Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Component - ComboBox[CB] #52

Open
6 of 10 tasks
prasanna1211 opened this issue Apr 23, 2020 · 11 comments · May be fixed by #63 or #55
Open
6 of 10 tasks

[RFC] Component - ComboBox[CB] #52

prasanna1211 opened this issue Apr 23, 2020 · 11 comments · May be fixed by #63 or #55
Labels
Status: Work in Progress 🛠 Someone is working on this Type: API discussion 💡 It's just a idea worth looking into, but doesn't mean it's priority.

Comments

@prasanna1211
Copy link
Contributor

prasanna1211 commented Apr 23, 2020

Definitition:

A Combo Box [CB] is an input widget with an associated popup that enables users to select a value for the combobox from a collection of possible values

Combo Box [CB] vs List Box [LB]

LB is simply a list of items, while a CB is a combination of a List box and an input that can be edited

Behaviours for Combobox v0.1

  1. When we type:
  • The logic for suggested values can be overriden by a custom filter function.
  • The highlighted value can be selected using mouse / keyboard.
  • The results should be filtered and only the results that match the pattern (logically based on the filter function) should appear.
  • The first element on the filtered list (the most closest option) should be highlighted and be present at the top.
  1. When we trigger dropdown:
  • A ghost of selected element should appear that should get cleared when we start typing.
  • By default all options should be visible when we trigger a dropdown to open state.
  1. Keyboard Navigations as per keyboard Navigations section

  2. Virtualized List The list must be scrollable, virtualized (preferably react-window)

  3. Dynamic popup positioning The popup should be dynamically positioned based on the window size.

Functionalities

1. API Fetchable: Results should be populated from a resolved promise and ability to pick first few elements out of it

2. Clearable The selected should be clearable by clear icon (or) typing during input focus.

3. Disabled option state: Few options can be disabled.

Import

Component Parts:

  • Combobox: The wrapper that provides the context and functionalities
  • ComboBoxInput: The Input component to get user input in a text field.
  • ComboboxList: The listbox that wraps the options. It provides the keyboard
  • ComboboxOption: Each option in the select.

Usage

<ComboBox>
  <ComboBoxInput />
  <ComboBoxPopper>
    <ComboBoxList>
      <ComboBoxOption />
    </ComboBoxList>
  </ComboBoxPopper>
</ComboBox>

Props

ComboBox Props (Provides Context composed Box(div))

  • multi
  • value
  • options
  • onChange
  • enableGhost
  • size

ComboBoxInput with GhostSelected Props(composes Input)

  • placeholder

ComboBoxPopper (composes Popper)

  • placement
  • skid
  • gutter

ComboBoxList(Listbox) Props (composes React-Window List)

  • React-Window Props
  • itemHeight
  • pageSize

ComboBoxOption Props (composes Box)

  • styleProps

Keyboard navigations:

Edit Box

Event Behaviour
Escape Dismisses the popup if it is visible. Optionally, if the popup is hidden before Escape is pressed, clears the combobox.
Enter Accepts the focused element in the popover. Handle automcomplete's cursor
Alt + ↓ Focus is not lost, open pop up
Alt + ↑ Focus is lost, open pop up
Character Types the character, opens popover and look for variation to what to happen?

Popup

Keyboard Behaviour
Enter Accepts the focused option close the popup, handle cursor of input.
Escape Closes the popup & focus to the combobox. Optional clear the input.
Down Arrow Focus and select next option cyclic?
Up Arrow Focus and select next option cyclic?
Left Arrow Focus to input without closing popup and handle cursor
Backspace Returns focus to input and deletes last character
Delete Returns focus to input and delete completely
Character Look for variations to what to happen?

Further Improvements

  • Support in forms
  • Accessibilities
  • Style variants
  • Get the Promise instead of resolved promise for isAsync
@timelessco timelessco locked and limited conversation to collaborators Apr 23, 2020
@navin-moorthy
Copy link
Collaborator

navin-moorthy commented Apr 23, 2020

Okay, I went through all the types of Combo-Box and their examples in WAI-ARIA practices.
Aren't going to do the basic select where the Combo-Box is not editable just shows the listbox to select any option(like a native select)?

Like: A basic single select in https://react-select.com/home

react-select

@sandeepprabhakaran
Copy link

Happy to get on a call to describe the feature set I'm after.

@sandeepprabhakaran
Copy link

Features required:
Ideal if we could achieve combobox + listbox behavior in a single component (ref downshift useselect) if not it's okay to have to components.

Definitely building 'dialog' variant.

  1. Searchable
  2. Autocomplete (by highlighting first result by default)
  3. Clearable
  4. API fetchable
  5. Disabled
  6. Multiselect
  7. Keyboard shortcuts (basic)
  8. Style-able / Composable with children
  9. Grouping (LOW)
  10. Creation if no result exists (LOW)
  11. Focus on combobox input should show current value or default placeholder, onKeyPress should clear the existing value and start searching for 'key'

.....

@navin-moorthy
Copy link
Collaborator

@prasanna1211, I think you might have missed the Right Key navigation support.

Keyboard Behaviour
Right Arrow Focus to input without closing popup and handle cursor

https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html

@navin-moorthy
Copy link
Collaborator

See Material UI - https://material-ui.com/components/autocomplete/
They have better combo-box too.

@navin-moorthy
Copy link
Collaborator

Should we always need react-window to render the options?
Like whatever be the no. of options.
What if the no. of options are less than 10.

@prasanna1211
Copy link
Contributor Author

@navin-moorthy Not necessarily only if the results are large. Need to have a hard limit.

@navin-moorthy
Copy link
Collaborator

Dynamic popup positioning The popup should be dynamically positioned based on the window size.

This is the default behavior of Popper, I guess we don't need to do anything for dynamic positioning.

@navin-moorthy
Copy link
Collaborator

@navin-moorthy Not necessarily only if the results are large. Need to have a hard limit.

Okay, got it.

@prasanna1211
Copy link
Contributor Author

@navin-moorthy Yes, our component should use Popper JS. That is the implication of that behaviour.

@navin-moorthy
Copy link
Collaborator

@navin-moorthy Yes, our component should use Popper JS. That is the implication of that behaviour.

Clear

@prasanna1211 prasanna1211 changed the title Proposed COMBOBOX RFC [WIP] COMBOBOX RFC Apr 30, 2020
@prasanna1211 prasanna1211 removed the WIP label Apr 30, 2020
@navin-moorthy navin-moorthy changed the title COMBOBOX RFC [RFC] Component - Combo Box[CB] May 6, 2020
@navin-moorthy navin-moorthy added Status: Work in Progress 🛠 Someone is working on this Type: API discussion 💡 It's just a idea worth looking into, but doesn't mean it's priority. and removed active labels May 15, 2020
@navin-moorthy navin-moorthy changed the title [RFC] Component - Combo Box[CB] [RFC] Component - ComboBox[CB] May 15, 2020
@navin-moorthy navin-moorthy linked a pull request May 15, 2020 that will close this issue
@navin-moorthy navin-moorthy linked a pull request May 18, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Status: Work in Progress 🛠 Someone is working on this Type: API discussion 💡 It's just a idea worth looking into, but doesn't mean it's priority.
Projects
None yet
3 participants