Skip to content

Fix ComboBox dropdown not scrolling to selected item when opened - #21764

Merged
MrJul merged 1 commit into
AvaloniaUI:mainfrom
zrt2399:fix_issue_21762
Jul 20, 2026
Merged

Fix ComboBox dropdown not scrolling to selected item when opened#21764
MrJul merged 1 commit into
AvaloniaUI:mainfrom
zrt2399:fix_issue_21762

Conversation

@zrt2399

@zrt2399 zrt2399 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

Fix ComboBox dropdown not scrolling to selected item when opened

What is the current behavior?

bugdemo

What is the updated/expected behavior with this PR?

fixed

How was the solution implemented (if it's not obvious)?

Updated ComboBox.TryFocusSelectedItem to always call ScrollIntoView(SelectedIndex) before attempting to resolve and focus the selected container. This ensures the selected item is realized and brought into view when the dropdown opens.

Added a regression test that opens a ComboBox with many items, scrolls the popup back to the top, closes it, and verifies reopening the dropdown focuses the selected item.

Checklist

Fixed issues

Fixes #21762

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0067436-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added bug backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 13, 2026

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrJul
MrJul added this pull request to the merge queue Jul 20, 2026
Merged via the queue into AvaloniaUI:main with commit 51bc95a Jul 20, 2026
11 checks passed
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComboBox dropdown does not scroll to the selected item when opened

3 participants