XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] StateLayout does not load initial state other than None

Open henda79 opened this issue 4 years ago • 9 comments

Description

When StateLayout is presented it always defaults to the None View regardless what is set in CurrentState. I maybe using this wrong but surely if I set CurrentState to Success, it would default to that view.

Steps to Reproduce

  1. Create a basic StateLayout, with 1 or more Views and add something to the "None" View
  2. Set StateLayout.CurrentState="Success" or whatever Views we created other than None
  3. When the page is presented it shows the None View.

Expected Behavior

I'd expect to see the View I set in CurrentState.

Actual Behavior

StateView always default's to None.

Basic Information

  • Version with issue: 1.0.3
  • Last known good version: none
  • IDE: VS 2109 16.8.4
  • Platform Target Frameworks:
    • iOS: not tested
    • Android: 8.1 API 27
    • UWP: not tested

I've not created a sample demo as Its very easy to reproduce.

henda79 avatar Mar 05 '21 13:03 henda79

Hi @henda79 thanks for reporting, could you please attach a reproduction repo? I have tried reproduce it in the sample App but was working as expected.

Cfun1 avatar Mar 05 '21 14:03 Cfun1

Hey @Cfun1, I thought it would have been easy to replicate as I had the issue pretty much OOB.

I've added it in my demo app which I use to report bugs to Syncfusion, so just ignore most of it. You'll see it loads to the 'None' View State Despite been explicitly set in the XAML.

Here's a link to it on my GitHub: https://github.com/henda79/ListViewDemo

henda79 avatar Mar 05 '21 14:03 henda79

I can confirm the described issue.

Cfun1 avatar Mar 29 '21 21:03 Cfun1

@Cfun1 not the same with #1122?

AndreiMisiukevich avatar Mar 29 '21 23:03 AndreiMisiukevich

@AndreiMisiukevich no not the same, in this issue when State="Success" (other than the default one None) following OnCurrentStateChanged oldValue = None, newValue = Success, up to here good but in StateViews is still empty at that point.

https://github.com/xamarin/XamarinCommunityToolkit/blob/f52349cebb3db02d695028e05cd295de73951426/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/StateLayout/StateLayoutController.shared.cs#L67

Cfun1 avatar Mar 29 '21 23:03 Cfun1

CC @sthewissen

AndreiMisiukevich avatar Apr 26 '21 22:04 AndreiMisiukevich

I experienced this issue (or at least a very similar one) while the AnimateStateChanges property was set to true. It was causing my default "None" view to always appear first, no matter what my initial bound CurrentState was set to, resulting in an ugly flash of unloaded content before my Loading state appeared.

Setting AnimateStateChanges="False" made my intended initial state (Loading) correctly appear first.

nicjay avatar Jun 16 '22 05:06 nicjay

I also have the same issue. The layout does not change for any properties. Thus far, setting the animation to false has not helped either.

mathewgrabau avatar Mar 18 '23 16:03 mathewgrabau

I opened this 2 years ago, I can't see it getting any attention as all focus is on MAUI. You could just use this a base for your own control and change the behaviour as desired.

henda79 avatar Mar 18 '23 20:03 henda79