Skip to content

Fix multiple ScrollContentPresenter.BringDescendantIntoView calls - #22001

Merged
MrJul merged 4 commits into
AvaloniaUI:mainfrom
MrJul:fix/scrollcontentpresenter-offset
Aug 27, 2026
Merged

MrJul merged 4 commits into
AvaloniaUI:mainfrom
MrJul:fix/scrollcontentpresenter-offset

Conversation

@MrJul

@MrJul MrJul commented Aug 17, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

This PR fixes ScrollContentPresenter.BringDescendantIntoView not being idempotent: calling the method several times in a row without arranging the control between the calls resulted in the offset incorrectly self-accumulating on each call.

This could happen naturally, for example if a StackPanel was used in a ComboBox (see #21973).

Fixed issues

@MrJul MrJul added bug backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Aug 17, 2026
@avaloniaui-bot

Copy link
Copy Markdown

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

@grokys grokys self-assigned this Aug 27, 2026
grokys
grokys previously approved these changes Aug 27, 2026

@grokys grokys 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! The only comment is a tiny nit - feel free to ignore if you don't feel it makes things clearer.

@avaloniaui-bot

Copy link
Copy Markdown

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

Co-authored-by: Steven Kirk <grokys@users.noreply.github.com>
@MrJul
MrJul enabled auto-merge August 27, 2026 08:15
@avaloniaui-bot

Copy link
Copy Markdown

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

@MrJul
MrJul added this pull request to the merge queue Aug 27, 2026
Merged via the queue into AvaloniaUI:main with commit 33b288f Aug 27, 2026
10 checks passed
@MrJul
MrJul deleted the fix/scrollcontentpresenter-offset branch August 27, 2026 10:11
MrJul added a commit to MrJul/Avalonia that referenced this pull request Sep 2, 2026
…aloniaUI#22001)

* Add failing test for ScrollContentPresenter

* Fix ScrollContentPresenter multiple BringDescendantIntoView

* Update src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs

Co-authored-by: Steven Kirk <grokys@users.noreply.github.com>

---------

Co-authored-by: Steven Kirk <grokys@users.noreply.github.com>
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Sep 2, 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 ItemFocused method does not correctly scroll to the selected item when ItemsPanel uses a non-virtualizing StackPanel

3 participants