Hello!
I am trying to improve the usability of the AutoCompleteInput in my application. My AutoCompleteInput has a lot of entries, since we look through a list of present and former patients in our hospital and pick one from the list. So the moment I give the AutoCompleteInput all IDs as completions, the list of choices gets very long, rendering it hard to use. I am trying to improve the behavior by filtering the completions and in the future we might have a more intelligent way of filtering. But unfortunately, as I update the completions while the user writes into the box, they do not show up instantly but only after the user types yet another letter. So the completions always show up one step too late.
Here I wrote a minimal example that shows the behavior. Surprisingly, I also never get the output of the print statements that are within the callback, making it hard to debug, but that might be another problem.
import panel as pn
from bokeh.models.widgets.inputs import AutocompleteInput
pn.extension()
import pandas as pd
import sys
import networkx as nx
import holoviews as hv
hv.extension('bokeh')
l = [str(i) for i in range(1000000)]
df = pd.DataFrame({"items": l})
sys.path.append('..')
overlay = "##Self-reloading Autocomplete"
search_box = AutocompleteInput()
layout = pn.Column(overlay, search_box)
def sb_autocomplete_callback(query):
print("Updated label: " + query)
search_box.completions = df[df["items"].str.contains(query)]["items"].to_list()
print("New suggestions")
def sb_picker_callback(item_id):
print(f"Item {item_id} picked")
search_box.on_change('value_input', lambda attr, old, new: sb_autocomplete_callback(new))
search_box.on_change('value', lambda attr, old, new: sb_picker_callback(new))
search_box.placeholder = "Input item ID here..."
layout.show()
Any ideas on how to make the completions show up right after they were changed?