Skip to content
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

ListDetailsView navigation data loss #3546

Closed
huwpascoe opened this issue Oct 27, 2020 · 5 comments · Fixed by #4255
Closed

ListDetailsView navigation data loss #3546

huwpascoe opened this issue Oct 27, 2020 · 5 comments · Fixed by #4255
Assignees
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 controls 🎛️ help wanted Issues identified as good community contribution opportunities in progress 🚧
Milestone

Comments

@huwpascoe
Copy link

Describe the bug

MasterDetailsView, navigation events are processed in incorrect order resulting in data loss for controls that use {x:Bind UpdateSourceTrigger=LostFocus} type binding.

Steps to Reproduce

    public class MyItem
    {
        public string MyName { get; set; }
        public string MyValue { get; set; }
    }

    public class ViewModel
    {
        public ObservableCollection<MyItem> Items { get; set; } = new ObservableCollection<MyItem>()
        {
            new MyItem(){ MyName = "Alice" },
            new MyItem(){ MyName = "Bob" },
        };
    }
    <Page.Resources>
        <DataTemplate x:Key="ListTemplate" x:DataType="local:MyItem">
            <TextBlock Text="{x:Bind MyName}" />
        </DataTemplate>
        <DataTemplate x:Key="DetailsTemplate" x:DataType="local:MyItem">
            <StackPanel Margin="16">
                <TextBlock Text="{x:Bind MyName}" FontSize="32" />
                <TextBox Header="Value" Text="{x:Bind MyValue, Mode=TwoWay}" />
                <TextBox Header="Dummy" />
            </StackPanel>
        </DataTemplate>
    </Page.Resources>
    <Grid>
        <controls:MasterDetailsView
          ItemsSource="{x:Bind ViewModel.Items}"
          ItemTemplate="{StaticResource ListTemplate}"
          DetailsTemplate="{StaticResource DetailsTemplate}"
          NoSelectionContent="Select an item" />
    </Grid>

Expected behavior

MasterDetailsView
1 ItemSelected
2 LostFocus => {x:Bind} saves data
3 Navigate

Actual Behavior

1 ItemSelected
2 Navigate => unsaved data overwritten
3 LostFocus

Screenshots

bug

Environment

NuGet Package(s): 
Microsoft.NETCore.UniversalWindowsPlatform
Microsoft.Toolkit.Uwp.UI.Controls

Package Version(s): 
6.2.10
6.1.1

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] May 2020 Update (19041)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [x] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] May 2020 Update (19041)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [x] 2019 (version: 16.7.5) 
- [ ] 2019 Preview (version: )

@huwpascoe huwpascoe added the bug 🐛 An unexpected issue that highlights incorrect behavior label Oct 27, 2020
@ghost ghost added the needs triage 🔍 label Oct 27, 2020
@ghost
Copy link

ghost commented Oct 27, 2020

Hello huwpascoe, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@Kyaa-dost
Copy link
Contributor

@huwpascoe Thanks for highlighting the issue. Do you want to work on it and create a PR?

@michael-hawker
Copy link
Member

Yeah, tested with a WinUI TabView and that works as expected. I imagine it has something to do with how we update the selected item and update the presenter from the selection somewhere here?

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/90871947640ccc1622ca9328c2c78aae27a241e7/Microsoft.Toolkit.Uwp.UI.Controls/MasterDetailsView/MasterDetailsView.cs#L106-L142

@michael-hawker michael-hawker added the help wanted Issues identified as good community contribution opportunities label Oct 27, 2020
@michael-hawker michael-hawker added this to the 7.0 milestone Oct 27, 2020
@Kyaa-dost Kyaa-dost modified the milestones: 7.0, 7.1 Feb 18, 2021
@michael-hawker michael-hawker changed the title MasterDetailsView navigation data loss ListDetailsView navigation data loss Aug 31, 2021
@ghost ghost added the In-PR 🚀 label Sep 2, 2021
@ghost ghost added the in progress 🚧 label Sep 7, 2021
@Rosuavio
Copy link
Contributor

Discovered this issue, could be related #4244. I am exploring a solution to both in my branch. #4222

@Rosuavio
Copy link
Contributor

@michael-hawker I don't believe that #4255 fixed that issue. #4222 correctly tests for the underlying cause of this issues but lacks a solution.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 29, 2021
@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Mar 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 controls 🎛️ help wanted Issues identified as good community contribution opportunities in progress 🚧
Projects
None yet
4 participants