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

fix: ComboBox show all items on open #2328

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

bmingles
Copy link
Contributor

@bmingles bmingles commented Jan 2, 2025

DH-18088 & DH-18087: ComboBox now clears search filter when opening the ComboBox unless it is triggered by user input.

Testing

menu_trigger="focus"

  • Clicking search input should open it unfiltered

Here's a script with a few different configurations

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()

@bmingles bmingles changed the title WIP: ComboBox show all items on open (DH-18088) fix: ComboBox show all items on open Jan 3, 2025
@bmingles bmingles marked this pull request as ready for review January 3, 2025 16:58
Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 11.76471% with 15 lines in your changes missing coverage. Please review.

Project coverage is 46.69%. Comparing base (ca5f6cd) to head (733a315).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ackages/jsapi-components/src/spectrum/ComboBox.tsx 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2328      +/-   ##
==========================================
- Coverage   46.71%   46.69%   -0.02%     
==========================================
  Files         704      704              
  Lines       39010    39045      +35     
  Branches     9747     9756       +9     
==========================================
+ Hits        18223    18234      +11     
- Misses      20776    20800      +24     
  Partials       11       11              
Flag Coverage Δ
unit 46.69% <11.76%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmingles bmingles marked this pull request as draft January 3, 2025 20:23
@bmingles bmingles marked this pull request as ready for review January 6, 2025 20:59
@bmingles bmingles requested a review from mofojed January 6, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant