Repository: holoviz/panel

Issue:
AutocompleteInput that allows non-pre-defined options as their value
**Is your feature request related to a problem? Please describe.**

This is not related to a problem.

**Describe the solution you'd like**

I am putting in a feature request for `AutocompleteInput` that allows non-predefined values as its value, as well as a feature request for `AutocompleteInput` to permit substring matching.

The use case is as follows: We have a database field that is free text but short, representing human-defined categories of stuff. (In our case, it's plates attached to experiments, where the experiment names are defined by humans.) 

At the moment, we use two text boxes, and tell our users to use the correct one: AutocompleteInput if they are attaching plates to an existing experiment, and a plain text input box if they are creating a new experiment. 

The front-end might be simplified by allowing users to enter the experiment name into the text box directly, and then choosing an existing experiment name from there. Permitting substring matching would be helpful in this case, for example we might have an experiment name that is "cherry-picking on mutant 53", but I might only remember 53 and enter it first.

**Describe alternatives you've considered**

I understand this may break the API compatibility with "single value, option selection" widgets. Hence, if this were a different widget, that would be cool too.

**Additional context**

No other additional context that I can think of.


Discussion:
I would like this feature. All of my use-cases in which I would have liked an auto-complete widget need to accept inputs other than the predefined options.
Indeed, this enhancement would significantly expand the applicability of this widget. 
So far, its purpose is to select a value from a very long but fixed list - but long lists often are long because people keep adding to them.

@philippjfr Perhaps some pointers on how to implement this could help move this forward?

P.S. The name `AutocompleteInput` (when heard in isolation) can also be misunderstood to imply that it accepts new values, just as `Input` typically does. I get the naming dilemma, though - it is currently using an `Input` to `Select`.
Having a brief look, the widget seems to build upon the `bokeh.models.widgets.AutocompleteInput` widget
https://github.com/holoviz/panel/blob/42065be49e87bccc81375424d350c5f4ef6bd491/panel/widgets/select.py#L194

and there already is a parallel issue https://github.com/bokeh/bokeh/issues/9605 I guess this feature should be added in bokeh.
@philippjfr The PR that adds this functionality in bokeh has been merged https://github.com/bokeh/bokeh/pull/10476#event-3753562265 and the new `restrict` field should be in bokeh 2.3.

Looking at the corresponding code in panel
https://github.com/holoviz/panel/blob/42065be49e87bccc81375424d350c5f4ef6bd491/panel/widgets/select.py#L182-L196
it's not entirely clear to me whether one needs to add the new `restrict` field in panel explicitly or whether it will be "inherited"?
It will indeed need to be mirrored into Panel as a parameter.
How should I go about adding this? Do I need to wait for bokeh 2.3.0 to be released?

I've asked them to make a 2.3.0dev0 release - I could increase the minimum bokeh version to that in the panel PR...

Edit: thanks for the quick reply, by the way!

Resolving patch:
diff --git a/panel/widgets/select.py b/panel/widgets/select.py
--- a/panel/widgets/select.py
+++ b/panel/widgets/select.py
@@ -19,7 +19,7 @@
 
 from ..layout import Column, VSpacer
 from ..models import SingleSelect as _BkSingleSelect
-from ..util import as_unicode, isIn, indexOf
+from ..util import as_unicode, isIn, indexOf, bokeh_version
 from .base import Widget, CompositeWidget
 from .button import _ButtonBase, Button
 from .input import TextInput, TextAreaInput
@@ -205,6 +205,11 @@ class MultiChoice(_MultiSelectBase):
     _widget_type = _BkMultiChoice
 
 
+_AutocompleteInput_rename = {'name': 'title', 'options': 'completions'}
+if bokeh_version < '2.3.0':
+    # disable restrict keyword
+    _AutocompleteInput_rename['restrict'] = None
+
 class AutocompleteInput(Widget):
 
     min_characters = param.Integer(default=2, doc="""
@@ -219,9 +224,11 @@ class AutocompleteInput(Widget):
     
     case_sensitive = param.Boolean(default=True)
 
+    restrict = param.Boolean(default=True)
+
     _widget_type = _BkAutocompleteInput
 
-    _rename = {'name': 'title', 'options': 'completions'}
+    _rename = _AutocompleteInput_rename
 
 
 class _RadioGroupBase(SingleSelectBase):


Test patch: