Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComboBox - searching items from table data source doesn't always open the picker #2115

Open
bmingles opened this issue Jun 27, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@bmingles
Copy link
Contributor

bmingles commented Jun 27, 2024

When searching for items in a ComboBox backed by a table data source, sometimes the picker opens to show results as you type. Sometimes it does not.

I've filed a bug with Spectrum to address the root cause: adobe/react-spectrum#6638

UPDATE 07/11: Spectrum closed my bug ticket in lieu of this one adobe/react-spectrum#5234

Reproduction Steps

Run the below script

Working Scenario

  1. Before selecting anything in the ComboBox, type 2024 very quickly (has to be quick to beat the debounce applying the change)
  2. Should see ComboBox open showing all items for 2024
  3. Clear the typing

Non-working Scenario

  1. This time, type 2024 slowly so that the filter gets applied before you finish typing.
  2. CombBox is no longer open
  3. If you backspace the 4, ComboBox will open briefly then close. Typing 4 again will not re-open the ComboBox
  4. If you backspace the 4 and type it again very quickly, it will re-open
from deephaven import empty_table, ui, time_table
import datetime

initial_row_count=5 * 8760 # 5 years
_items = time_table("PT6H", start_time=datetime.datetime.now() - datetime.timedelta(hours=initial_row_count)).update([])

key_column="Timestamp"

@ui.component
def ui_combo_box(items):
    value, set_value = ui.use_state()

    combo = ui.combo_box(
        items,
        key_column=key_column,
        label_column=key_column,
        label=key_column,
        on_selection_change=set_value,
        selected_key=value,
    )

    # Show current selection in a ui.text component
    text = ui.text("Selection: " + str(value))

    return combo, text


my_combo_box = ui_combo_box(_items)

I believe the root cause is the Spectrum ComboBox only shows the popup after the user types and there are items in the source array. Changing from an empty items array to one with data won't open the popup until user types.

Here's the impact of this:

  1. User types 202 which gets applied to the list and results in no matching results due to how our date filter works.
  2. User types 4
  3. ComboBox still has empty items, so it doesn't open even though user typed
  4. We apply the filter to jsapi which results in items array containing all 2024 data. This updates the ComboBox, but it doesn't automatically open when items change, only when user types
  5. User backspaces 4 slowly. This flickers for a moment the 2024 data since it still exists in items, but then 202 is applied as filter resulting in empty items array. ComboBox rightly closes due to empty data
  6. Typing 4 again repeats the issue in step 3.
  7. Backspacing 4 and retyping quickly opens because the filter resulting in empty items is never applied, and user has typed while there are still results in items

I'm not sure how to get around this but seems we need a way to force the ComboBox to open if the items array goes from empty to populated as a result of a user key stroke.

Note: Worth mentioning that there are 2 additional menuTrigger modes that change the behavior of the dropdown opening that will need to be accounted for in whatever solution we may find.

@bmingles bmingles added bug Something isn't working triage Issue requires triage labels Jun 27, 2024
@vbabich vbabich added this to the Backlog milestone Jul 2, 2024
@vbabich vbabich removed the triage Issue requires triage label Jul 2, 2024
bmingles added a commit that referenced this issue Jul 3, 2024
Jsapi support for ComboBox. Includes some splitting out of existing
Picker logic to make code re-usable.

Should be testable with plugins PR
deephaven/deephaven-plugins#588
I have also deployed an alpha
[0.83.1-alpha-combobox.8](https://www.npmjs.com/package/@deephaven/components/v/0.83.1-alpha-combobox.8)
if you need it, although should only matter for types I think.

```python
from deephaven import empty_table, ui, time_table
import datetime


# Change this to test different data types
key_column="Timestamp"


initial_row_count=5 * 8760 # 5 years in hours

# Tick every 6 hours (makes it easier to test Timestamp filters for a whole day like `2024-01-02`)
_items = time_table("PT6H", start_time=datetime.datetime.now() - datetime.timedelta(hours=initial_row_count)).update([
    # Timestamp column also implicitly included in `time_table`
    "Int=new Integer(i)",
    "Long=new Long(i)",
    "BigInt=new java.math.BigInteger(``+i)",
    "String=new String(`a`+i * 1000)",
])


@ui.component
def ui_combo_box(items):
    value, set_value = ui.use_state("")

    combo = ui.combo_box(
        ui.item_table_source(
            items,
            key_column=key_column,
            label_column=key_column,
        ),
        label=key_column,
        on_selection_change=set_value,
        menu_trigger="focus",
        selected_key=value,
    )

    # Show current selection in a ui.text component
    text = ui.text("Selection: " + str(value))

    return combo, text


my_combo_box = ui_combo_box(_items)
```

There is a known issue with inconsistent open as you type for table data
sources.
#2115

resolves #2074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants