Improve ComboBox scrolling and selection interaction - #22018
Conversation
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
| if (IsDropDownOpen && dropDownItem.IsFocused && dropDownItem.IsArrangeValid) | ||
| { | ||
| dropDownItem.BringIntoView(); | ||
| var margin = Presenter?.Margin ?? default; |
There was a problem hiding this comment.
This feels like a hack - I think this should be fixed in ScrollContentPresenter.BringDescendantIntoView for the general case.
There was a problem hiding this comment.
By the way, should BringDescendantIntoView respect only the child's margin, or both the child's margin and its own padding?
| { | ||
| var selectedIndex = SelectedIndex; | ||
| if (IsDropDownOpen && selectedIndex != -1) | ||
| if (IsDropDownOpen && AutoScrollToSelectedItem && selectedIndex != -1) |
There was a problem hiding this comment.
This does feel like a valid fix though.
|
It might be worth closing this PR and opening two separate PRs with the separate fixes? |
Agreed. |
|
I’ll close this PR and follow your suggestion by opening two separate PRs. |
|
You can test this PR using the following package version. |
What does the pull request do?
ItemsPresentermargin when bringing a focusedComboBoxIteminto view.AutoScrollToSelectedItemwhen opening the ComboBox dropdown.What is the current behavior?
When a ComboBox dropdown uses an

ItemsPresentermargin, focusing an item can scroll only to the item bounds and ignore the visual margin.Additionally, opening a ComboBox with
AutoScrollToSelectedItem="False"still scrolls to and focuses the selected item.What is the updated/expected behavior with this PR?
The focused item is brought into view together with the presenter margin, ensuring correct scrolling with both the Fluent and Fluent v2 themes.


When
AutoScrollToSelectedItemis disabled, opening the dropdown does not change its scroll offset.Checklist