Skip to content

Fix initial logical scrollable state #13066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 1, 2023
Merged

Conversation

grokys
Copy link
Member

@grokys grokys commented Sep 28, 2023

What does the pull request do?

As described in #13064, the initial state for a ILogicalScrollable control isn't correctly synced to the owner ScrollViewer.

This seems to have been introduced in #10803 because at the time that the subscriptions in ScrollContentPresenter are set up, the _owner is still null and so when the changes arrive at OnPropertyChanged they're not written to the owner.

@TomEdwardsEnscape you wrote #13064, is moving the _owner assignment like this going to break anything else do you think? Was it placed after the subscription setup for a reason?

Fixed issues

Fixes #13064

Since #10803, the `ScrollContentPresenter.Content` binding is managed internally, not via a binding in the template.
@grokys grokys added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Sep 28, 2023
@@ -1182,7 +1182,6 @@ private static FuncControlTemplate CreateScrollViewerTemplate()
new ScrollContentPresenter
{
Name = "PART_ContentPresenter",
[~ScrollContentPresenter.ContentProperty] = parent.GetObservable(ScrollViewer.ContentProperty).ToBinding(),
Copy link
Member Author

@grokys grokys Sep 28, 2023

Choose a reason for hiding this comment

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

While investigating this I noticed that some tests still have a content binding in their ScrollViewer templates which shouldn't be the case ever since #10803. These tests are unrelated, but having this binding here may make the tests incorrect (as the new test add in this PR passed with this binding in place for example).

@@ -323,6 +323,7 @@ internal void AttachToScrollViewer()
}

_ownerSubscriptions?.Dispose();
_owner = owner;
Copy link
Member Author

Choose a reason for hiding this comment

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

This line being moved is the actual fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be OK.

I think I put it after subscription setup because the property changed code just sets values on the owner, but when this method is executing the owner is where those values came from in the first place. So that seems like a redundant assignment each time.

If it fixes the bug though, then clearly there is some other side effect that I'm not aware of.

Copy link
Member Author

@grokys grokys Sep 30, 2023

Choose a reason for hiding this comment

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

Yeah the side effect is that it pushes the ScrollViewer.Content to the SCP, which causes the SCP to read the ILogicalScrollable properties, which need to then be synced back with the ScrollViewer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a comment in the code about the rationale would be helpful for future eyes on this.

@avaloniaui-team
Copy link
Contributor

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

@grokys grokys enabled auto-merge September 30, 2023 09:58
@grokys grokys added this pull request to the merge queue Sep 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2023
@maxkatz6 maxkatz6 merged commit bf1be0c into master Oct 1, 2023
@maxkatz6 maxkatz6 deleted the fixes/13064-logical-scrollable branch October 1, 2023 04:14
maxkatz6 added a commit that referenced this pull request Oct 1, 2023
grokys added a commit that referenced this pull request Oct 2, 2023
* Add failing test for #13064

* Remove Content binding from ScrollViewer template.

Since #10803, the `ScrollContentPresenter.Content` binding is managed internally, not via a binding in the template.

* Assign owner before doing subscriptions.

Fixes #13064.
@grokys grokys added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Oct 14, 2023
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.

ILogicalScrollable initial state not synced with ScrollViewer.
5 participants