carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.6k stars 1.76k forks source link

Combobox unique value ☂️ #6102

Open laurenmrice opened 4 years ago

laurenmrice commented 4 years ago

Acceptance criteria


### Unique value
- [ ] https://github.com/carbon-design-system/carbon/issues/13412
- [ ] https://github.com/carbon-design-system/carbon/issues/13902
- [ ] https://github.com/carbon-design-system/carbon/issues/13903
- [ ] https://github.com/carbon-design-system/carbon-design-kit/issues/688
- [ ] https://github.com/carbon-design-system/carbon/issues/14006
- [ ] https://github.com/carbon-design-system/carbon/pull/13904
- [ ] https://github.com/carbon-design-system/carbon-website/issues/3579
### Focus state changes
- [ ] https://github.com/carbon-design-system/carbon-design-kit/issues/768
- [ ] https://github.com/carbon-design-system/carbon/issues/15698
- [ ] https://github.com/carbon-design-system/carbon-website/issues/3935
- [ ] https://github.com/carbon-design-system/carbon/issues/16512
### Refactor and Autocomplete
- [ ] https://github.com/carbon-design-system/carbon/issues/14684
- [ ] https://github.com/carbon-design-system/carbon/issues/14007
cbix commented 3 years ago

I do need this option for a project, would be great to see an implementation! Currently it works really inconsistently:

Demo: Peek 2020-11-25 10-11

dpklahn commented 3 years ago

The work my team is doing would greatly benefit from this functionality as well. We'd like to allow the user to type in their own credentials OR select from a list of saved (and encrypted) credentials.

We'd also like to indicate when a selection has been made vs user input. In the example below we proposed an icon next to component when a selection is made, but it would be great to have a built in "state" for the two options.

Combo box.pdf

guigueb commented 3 years ago

Issue carbon-design-system/carbon#6102 and this issue carbon-design-system/carbon#8170 are related. carbon-design-system/carbon#6102 talks about adding the ability to add values not in the item list carbon-design-system/carbon#8170 talks about dis-allowing values that are not in the item list

Both are good options and should be supported. By default the ComboBox should only allow items that can be found in the list. An additional prop (?allowUnmatchedItems?) would allow users to type in and retain a value that does not match an item.

The caveat for retaining a value is the need for validation to ensure the retained value is good.

Further along the lines of what the user can type in...., we should have a way to always validate what is typed in. ie: if the drop down values are all integers - there should be some way to limit the user input to integers.

godivareisen commented 3 years ago

The DataStage team would benefit from being able to add unique input values via the combo-box. We have many cases where users have to specify what specific date format to use, and we cannot include every possible date format in the dropdown list. Ideally, we would be able to list commonly used date formats in the dropdown, but users would be able to enter other date formats that aren't part of the default list.

grahamharper commented 3 years ago

+1 for this. We required this functionality for a time input control where the user could pick from a list of times or enter a custom time value. We had to copy the component and add the feature in our codebase temporarily to meet a delivery date. Ideally the combobox would support this as it's expected functionality.

guigueb commented 3 years ago

I did this by...

Something that would make this (and other free form find/search components) better, is to set the TYPE of input. ie:

grahamharper commented 3 years ago

@guigueb is your code available to share?

ConradSchmidt commented 1 year ago

What about this solution?

const [items, setItems] = useState(values);
return <ComboBox
    titleText="Column"
    items={items}
    onInput={e => setItems(e.target.value ? [...values, e.target.value] : values)}
    />

It always adds (non-empty) inputs at the end of the dropdown and selects it if no other is matching

custom_combo ("Other" and "Misc" are not part of the values)

tay1orjones commented 1 year ago

I don't see that the (newly updated!) wai-aria guidance site shows an example of this anymore. https://www.w3.org/WAI/ARIA/apg/patterns/combobox/#examples

Is this still a valid pattern under the combobox and listbox roles?

sstrubberg commented 1 year ago

Image

sstrubberg commented 1 year ago

From Gower: I think that is more a sign of what they’re focusing on than that it isn’t supported. If you have a look at the preamble, you’ll see them talk about select-only versus editable, and then different kinds of editable as well. https://www.w3.org/WAI/ARIA/apg/patterns/combobox/

sstrubberg commented 1 year ago

To everyone watching this issue, we will be doing some research in the next couple of sprints to inform the design spec and implementation. If there are any examples of this enhancement in the PAL community, please chime in with examples.