Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] When expanding the last tile in a Grouped Accordion ListView, the content is not visible #10030

Open
doriangh opened this issue Mar 19, 2020 · 5 comments

Comments

@doriangh
Copy link

Description

When having a Grouped ListView with accordions, when there are enough groups so it can fill the whole screen and even more, when going straight to the bottom group, it does not come into view. It expands under the screen.

Steps to Reproduce

  1. Create a Grouped Accordion ListView
  2. Bind enough data as to be able to scroll
  3. Expand the last group

Expected Behavior

The list view slightly scrolls up as to place into view the content of the group

Actual Behavior

The group expands but the data is underneath, and the user has to scroll to be able to see the data

Basic Information

  • Version with issue: 4.4.0.991477
  • IDE: Visual Studio Mac
  • Platform Target Frameworks:
    • iOS: 13.3
    • Android: 9.0
  • Nuget Packages: Xamarin.Forms, Xamarin.Essentials
  • Affected Devices: iOS, Android
@doriangh doriangh added s/unverified New report that has yet to be verified t/bug 🐛 labels Mar 19, 2020
@pauldipietro pauldipietro added this to New in Triage Mar 19, 2020
@jfversluis
Copy link
Member

Hi @doriangh thanks for the report.

When you talk about "Grouped Accordion ListView" is that something custom you have created or a third-party control or something?

It would be great if you could provide a little reproduction project that shows the issue. Same goes for the other issue you just opened.

@jfversluis jfversluis added a/listview Problems with the ListView/TableView p/Android p/iOS 🍎 s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Mar 19, 2020
@jfversluis jfversluis moved this from New to Needs Info in Triage Mar 19, 2020
@doriangh
Copy link
Author

doriangh commented Mar 19, 2020

Hello! Here's a reproduction link.
https://github.com/doriangh/AccordionListViewProblem
As I can see the groups don't have the children data inside, but it doesn't matter as the group expands.

The reproduction link works for both issues as closing the group calls Clear() method.

Thank you!

@samhouts samhouts moved this from Needs Info to New in Triage Mar 20, 2020
@samhouts samhouts moved this from New to Needs Info in Triage Mar 20, 2020
@jfversluis
Copy link
Member

So, I'm not really sure if this is a bug. While this is clearly possible with a ListView, I don't think this was an intended use-case. I have however managed to come up with (some kind of) workaround.

Depending on how you want to reference your ListView you can do something like this.

public ICommand ExpandGroup => new Command<TestItemGroupModel>(group =>
{
       if (!group.Expanded && GroupItems.Any(x => x.Expanded))
           GroupItems.FirstOrDefault(x => x.Expanded).Expanded = false;
      group.Expanded = !group.Expanded;

      // This was added
      MessagingCenter.Send(this, "scrollit");
});
        public ItemsPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new ItemsViewModel();

            // This was added
            MessagingCenter.Subscribe<ItemsViewModel>(this, "scrollit", m => ItemsListView.ScrollTo(m.GroupItems.FirstOrDefault(i => i.Expanded)?[0], ScrollToPosition.Start, false));
        }

You can do it a bit differently and definitely add error handling, but this way the opened group will scroll into view.

You might have better luck with using the CollectionView where you have more fine-grained control over scrolling and such, or maybe keep your eye on #9044

@doriangh
Copy link
Author

doriangh commented Mar 27, 2020

Thank you very much for your reply. I have tested the workaround and can confirm it is working.
I have tried using a CollectionView, but I had no success in converting from ListView to CollectionView with my approach of an accordion ListView. Maybe if anyone can figure out a way, I'd be thankful.
So far, with Xamarin.Forms 4.5 the app crashes on Clear() method. And with Forms 4.4 the header layout I am using does not render well, and the header trigger is not firing.

But thanks anyway!

@PureWeen
Copy link
Contributor

So far, with Xamarin.Forms 4.5 the app crashes on Clear() method. And with Forms 4.4 the header layout I am using does not render well, and the header trigger is not firing.

@doriangh can you log a bug? It'll be quicker to get this all working and fixed in CollectionView then it will be with ListView

@PureWeen PureWeen added e/6 🕕 6 and removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified labels Mar 28, 2020
@PureWeen PureWeen moved this from Needs Info to Ready For Work in Triage Mar 28, 2020
@samhouts samhouts added this to To do in iOS Ready For Work Mar 30, 2020
@samhouts samhouts removed this from Ready For Work in Triage Mar 30, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Development

No branches or pull requests

4 participants