Skip to content

Fix Sticky ScrollHeader causing unwanted scrolling with Popups on ListItems #3568

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
3 commits merged into from
Nov 24, 2020

Conversation

Difegue
Copy link
Contributor

@Difegue Difegue commented Nov 17, 2020

Fixes #3415

I took a quick look at the ScrollHeader bug and it was simple enough so:

The Scrollheader's StickyHeaderBehavior adjusts scrolling when focusing an element of the ScrollViewer if it's slightly hidden by the header. This imitates standard ScrollViewer behavior.
However, ScrollViewer.GotFocus also triggers if we open a Flyout on a ListItem, but since the scrolling calculation didn't plan for that, it ends up scrolling the list by the height of the Flyout.

An easy fix for this is to check if the focused element is really part of the list and not just a popup, which can be done by checking if the element has a parent or not.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

If a Popup/Flyout of any kind is assigned to either the ListView or its items, opening it by right-click will scroll the ListView by the height of the Flyout if a Sticky ScrollHeader is used.

The bug can be easily repro'd in the sample app's ScrollHeader page by adding a Flyout to its ListView:

<ListView.ContextFlyout>
         <Flyout>
            <Button Content="Hello!" />
        </Flyout>
</ListView.ContextFlyout>

What is the new behavior?

Showing the Flyout no longer scrolls the ListView.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Nov 17, 2020

Thanks Difegue for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Kyaa-dost November 17, 2020 16:50
@ghost ghost added bug 🐛 An unexpected issue that highlights incorrect behavior extensions ⚡ sample app 🖼 labels Nov 17, 2020
@Difegue Difegue force-pushed the 3415-flyout-stickyscrollheader branch from df9d208 to 2036aaa Compare November 17, 2020 16:51
Copy link
Contributor

@Kyaa-dost Kyaa-dost left a comment

Choose a reason for hiding this comment

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

Thanks, @Difegue!! Looks good to me 🚀

@ghost
Copy link

ghost commented Nov 24, 2020

Hello @michael-hawker!

Because this pull request has the auto merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 001c5c4 into CommunityToolkit:master Nov 24, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScrollHeader may cause ListView to scroll unexpectedly
4 participants