Commit c08bb7b
authored
fix: ComboBox show all items on open (#2328)
DH-18088 & DH-18087: ComboBox now clears search filter when opening the
ComboBox unless it is triggered by user input.
### Testing
- Typing in a combobox should open it filtered by the search text
- Clicking the dropdown should open the CombBox unfiltered
- Typing while open should filter results
> Note that there seems to be a Spectrum bug that can cause some weird
scrolling behavior when typing in an opened ComboBox
adobe/react-spectrum#7573
#### menu_trigger="focus"
- Clicking search input should open it unfiltered
Here's a script with a few different configurations
```python
import deephaven.ui as ui
from deephaven import time_table
import datetime
# Ticking table with initial row count of 200 that adds a row every second
initial_row_count = 200
_table = time_table(
"PT1S",
start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count),
).update(
[
"Int=new Integer(i)",
"Text=new String(`Display `+i)",
]
)
item_list = [ui.item(f"Display {i}") for i in range(1, 201)]
# Basic ComboBox
@ui.component
def ui_combo_box_basic():
value, set_value = ui.use_state("Display 91")
return ui.combo_box(
item_list,
label=f"Basic ({value})",
selected_key=value,
on_change=set_value,
width="size-3000"
)
# Uncontrolled ComboBox (Table source)
@ui.component
def ui_combo_box_uncontrolled(table):
value, set_value = ui.use_state("")
combo1 = ui.combo_box(
ui.item_table_source(table, key_column="Text", label_column="Text"),
default_selected_key="Display 92",
label=f"Uncontrolled Table Source ({value or 'None'})",
on_change=set_value,
width="size-3000"
)
return combo1
# Controlled ComboBox (Table source)
@ui.component
def ui_combo_box_controlled(table, menu_trigger):
value, set_value = ui.use_state("Display 93")
combo1 = ui.combo_box(
ui.item_table_source(table, key_column="Text", label_column="Text"),
selected_key=value,
label=f"Controlled Table Source ({value}) {menu_trigger or ''}",
menu_trigger=menu_trigger,
on_change=set_value,
width="size-3000"
)
btn = ui.button("Set Value", on_press=lambda: set_value("Display 104"))
return combo1, btn
# Controlled input ComboBox (Table source)
@ui.component
def ui_combo_box_input_controlled(table, menu_trigger):
input_value, set_input_value = ui.use_state("Display 94")
value, set_value = ui.use_state("Display 94")
combo1 = ui.combo_box(
ui.item_table_source(table, key_column="Text", label_column="Text"),
input_value=input_value,
on_input_change=set_input_value,
default_selected_key=value,
label=f"Controlled Input Table Source ({value}) {menu_trigger or ''}",
menu_trigger=menu_trigger,
on_change=set_value,
width="size-3000"
)
btn = ui.button("Set Input", on_press=lambda: set_input_value("Display 104"))
return combo1, btn
# Layout
@ui.component
def ui_layout():
return (
ui_combo_box_basic(),
ui_combo_box_uncontrolled(_table),
ui_combo_box_controlled(_table, None),
ui_combo_box_controlled(_table, "focus"),
ui_combo_box_input_controlled(_table, None),
)
tests = ui_layout()
```1 parent 3608b15 commit c08bb7b
6 files changed
Lines changed: 60 additions & 12 deletions
File tree
- packages
- components
- src/spectrum
- comboBox
- picker
- jsapi-components/src/spectrum
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
| |||
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
63 | | - | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
68 | | - | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
25 | 44 | | |
26 | 45 | | |
27 | 46 | | |
28 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
29 | 67 | | |
30 | 68 | | |
31 | 69 | | |
32 | 70 | | |
33 | 71 | | |
| 72 | + | |
34 | 73 | | |
35 | 74 | | |
36 | 75 | | |
| |||
0 commit comments