Skip to content

ComboBox resets selected item to the first one on Esc key press when the drop-down is closed #10767

Open
@kirill-zakharov-altium

Description

@kirill-zakharov-altium

Description

If you focus a ComboBox and press the Esc key, it resets the selected item to the first one. It happens when the ComboBox's drop-down is closed. In the .NET Framework 4.8, it didn't happen.

See the video:
https://github.com/user-attachments/assets/5db212dd-2d89-4fe1-b00d-07d23ace75f0

Here are the repro projects:
ComboBoxTest.zip

Reproduction Steps

  • Create a new WPF project in .NET6,8,9 (the bug is reproducible in all 3 versions)
  • Add the following code into the MainWindow.xaml into the root Window tag:
    <ComboBox
        Width="100"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        SelectedIndex="0">
        <ComboBox.Items>
            <ComboBoxItem>1</ComboBoxItem>
            <ComboBoxItem>2</ComboBoxItem>
            <ComboBoxItem>3</ComboBoxItem>
        </ComboBox.Items>
    </ComboBox>
  • Run the project, click on the combo-box, click on the 3rd item in the drop-down, and then press the Esc key (when the drop-down is closed).

Expected behavior

The selected item must not be changed on the Esc key press and must remain "3". That's how it worked in .NET Framework 4.8.

Actual behavior

The selected item is reset to "1" after the Esc key press. That's very counterintuitive.

Regression?

It's a regression to the .NET Framework 4.8 version.

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateRequires further investigation by the WPF team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions