Open nathanmmiller opened 2 months ago
allowFreeForm
is in #2409
Currently Combobox has inputProps
which supports some of these
allowFreeForm
is in #2409Currently Combobox has
inputProps
which supports some of these
Thank you @origami-z - I've subscribed to #2409 and will patiently await that. The rest of these - are inputProps documented, or rather, is there a list of which of the "some" are supported and which of the others should be part of this feature request?
OK I've played around with inputProps and also with some of the events and I'm able to do most of this, though there are still some missing pieces. I think this is the list of what's missing to be able to support this use case:
if (ignoreEsc && reason === "escape-key") return;
[I will happily raise a PR for this if y'all agree with this approach.]!event.relatedTarget.classList.contains("saltOptionList")
but I imagine that's fragile for the future as it's clearly a workaround.
Area
UI Components
The problem
The use case is basically as follows: We have a multi-select, free-form-allowed combobox that we want to support the following behavior:
So for example, there could be the following scenario. Items in Combobox: Red, Blue, Baby Blue, Green, Mauve User types: "b" Combobox shows Blue, Baby Blue User arrows down to Blue and selects it "Blue" is selected, input still shows "b" and Combobox still shows Blue, Baby Blue User hits [Esc] Combobox shows all options, input is blank User types M Combobox shows "Mauve" User clicks outside the combobox Combobox input is cleared, only Blue is selected.
The solution
Currently, in the older design system we currently use, there's a concept of "InputProps" that control the Input of the combobox. We use something like this (not real code):
Additionally, the combobox itself also has an "inputValue" prop that we then can feed with the "input" state from above. And there's also an "allowFreeForm" that this all ties into, allowing us to actually "select" options that aren't there when the text controlled by "input" is [Enter]'d.
Alternatives and examples
I can provide examples internal to JPMC if someone pings me.
Are you a JPMorgan Chase & Co. employee?