Hi all,
I’d like my users to select from an existing list in a dropdown, but also allow them to add a new item if needed.
Obviously I can create separate elements like a button to add a new item, a text input to enter it, etc.
But I’d like to solve this more elegantly using a single dropdown.
From my experience and after a thorough read of the documentation, this doesn’t seem natively possible.
I’ve been thinking of the following hack using a clientside callback (required to best track typing speed).
- Ouput is the ‘options’ of the dropdown
- Input is the ‘search_value’
- State of ‘options’
- Code checks if search_value is not in ‘options’, in which case it adds it there. It also stores in a dcc.store the new option and on the next callback fire (character added/deleted) it deletes the old “new” option and adds a new one.
I didn’t implement this yet so not sure how cleanly it will actually work. Will update after I do.
Can anyone suggest more or better solutions?
Thank you.