Skip to content

After trying select value in a Combobox that have already selected, Combobox remains expanded. #168

Description

@elbit61

Hello, there
I met a problem in a Select method for a combobox: after try to select value that have already selected, combo box remains in expanded state.

This is help me:

public static void SelectItemAndClose(this ComboBox target, string itemText)
{
target.Select(itemText);
CollapseComboBox(target);
}

public static void SelectItemAndClose(this ComboBox target, int index)
{
target.Select(index);
CollapseComboBox(target);
}

private static void CollapseComboBox(ComboBox target)
{
var ecp = target.AutomationElement.GetPattern(ExpandCollapsePattern.Pattern);
if (ecp != null && ecp.Current.ExpandCollapseState == ExpandCollapseState.Expanded)
{
ecp.Collapse();
}
}

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions