Skip to content

fix: ComboBox dropdown auto-closes when inside Menu control#1807

Open
DineshSolanki wants to merge 1 commit into
HandyOrg:masterfrom
DineshSolanki:fix/1467-combobox-menu-dropdown-close
Open

fix: ComboBox dropdown auto-closes when inside Menu control#1807
DineshSolanki wants to merge 1 commit into
HandyOrg:masterfrom
DineshSolanki:fix/1467-combobox-menu-dropdown-close

Conversation

@DineshSolanki

Copy link
Copy Markdown

Problem

ComboBox dropdown auto-closes immediately when placed inside a

control. The dropdown opens on mouse-down but closes on mouse-up before the user can make a selection.

Reproduction:

<Menu IsMainMenu="True">
    <hc:ComboBox ItemsSource="{Binding DataList}" SelectedIndex="0"/>
</Menu>

Introduced in: 8e707a6 ("enhance: optimize input elements") — which replaced the standard WPF ToggleButton (with ClickMode="Press" and built-in mouse capture) with a custom ToggleBlock control that lacked mouse capture.

Root Cause

WPF's Menu control uses PopupControlService to track mouse events and manage popup lifecycles. When the user clicks the ComboBox inside a Menu:

Fix

Add mouse capture to ToggleBlock.OnMouseDown to prevent WPF's Menu PopupControlService from closing the parent popup on mouse-up. Without capture, the Menu sees the mouse-up event and closes the hosting MenuItem popup, which cascades to close the ComboBox dropdown.

Fixes #1467

Add mouse capture to ToggleBlock.OnMouseDown to prevent WPF's
Menu PopupControlService from closing the parent popup on mouse-up.
Without capture, the Menu sees the mouse-up event and closes the
hosting MenuItem popup, which cascades to close the ComboBox dropdown.

Fixes HandyOrg#1467
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.

Combo box automatically closing as soon as opened when added in a Menu control

1 participant