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

macOS: TableView group name does not update #321

Closed
sergey-tihon opened this issue Feb 7, 2019 · 7 comments
Closed

macOS: TableView group name does not update #321

sergey-tihon opened this issue Feb 7, 2019 · 7 comments
Labels
t/bug Something isn't working as expected

Comments

@sergey-tihon
Copy link

sergey-tihon commented Feb 7, 2019

I slightly modified view of template application

    let view (model: Model) dispatch =
        View.ContentPage(
          content = View.StackLayout(
            padding = 20.0, verticalOptions = LayoutOptions.Center,
            children = [
                View.TableView(
                    intent = TableIntent.Form,
                    items = [
                        (sprintf "%d" model.Count, [
                            View.TextCell(
                                text = sprintf "%d" model.Count
                            )
                        ])
                    ]
                  )
                View.Button(text = "Increment", command = (fun () -> dispatch Increment), horizontalOptions = LayoutOptions.Center)
                View.Button(text = "Decrement", command = (fun () -> dispatch Decrement), horizontalOptions = LayoutOptions.Center)
            ]))

when I click buttons, content of View.TextCell updates correctly, but group name does not
2019-02-07 22 49 26

If it is by design, then it is confusing.

Repro is here - https://github.com/sergey-tihon/Fabulous.BugRepros/tree/master/TableViewUpdate

sergey-tihon added a commit to sergey-tihon/Fabulous.BugRepros that referenced this issue Feb 7, 2019
@TimLariviere
Copy link
Member

Thanks for reporting.
I think I know why, had a similar issue with ListViewGrouped a few months ago.
I'll try to fix that today.

@TimLariviere
Copy link
Member

TimLariviere commented Feb 8, 2019

Took a look. We were indeed missing the update of the title.
Though, adding this line doesn't fix it. I think it might be an issue in Xamarin.Forms.

I've added this code in the update of TableView.Items

System.Console.WriteLine (sprintf "Try setting Title. Current '%s', New '%s'" target.Title newTitle)
target.Title <- newTitle
System.Console.WriteLine (sprintf "Value setted. Expected '%s', Got '%s'" newTitle target.Title)

It prints

-- First click
Try setting Title. Current 'Videos', New 'Issue321 fixed'
Value setted. Expected 'Issue321 fixed', Got 'Issue321 fixed'

-- Second click
Try setting Title. Current 'Issue321 fixed', New 'Videos'
Value setted. Expected 'Videos', Got 'Videos'

The title on the UI stays the same, even though the Xamarin.Forms control has been updated...
And according to docs, it supports binding so it should update when changed.

@TimLariviere
Copy link
Member

The issue is also present on iOS and Android.

@TimLariviere
Copy link
Member

Ok, it's not an XF issue.
This works on iOS, Android, macOS and UWP.

<StackLayout>
    <TableView Intent="Form">
        <TableRoot>
            <TableSection x:Name="Section" Title="0">
                <TextCell x:Name="Cell" Text="0" />
            </TableSection>
        </TableRoot>
    </TableView>
    <Button x:Name="Increment" Text="Increment" />
    <Button x:Name="Decrement" Text="Decrement" />
</StackLayout>
public partial class MainPage : ContentPage
{
    public int _count = 0;

    public MainPage()
    {
        InitializeComponent();
        Increment.Clicked += Increment_Clicked;
        Decrement.Clicked += Decrement_Clicked;
    }

    private void Decrement_Clicked(object sender, EventArgs e)
    {
        _count--;
        Section.Title = _count.ToString();
        Cell.Text = _count.ToString();
    }

    private void Increment_Clicked(object sender, EventArgs e)
    {
        _count++;
        Section.Title = _count.ToString();
        Cell.Text = _count.ToString();
    }
}

@TimLariviere TimLariviere added this to the 1.0.0 milestone Feb 11, 2019
@TimLariviere TimLariviere added t/bug Something isn't working as expected controls labels Feb 11, 2019
@TimLariviere
Copy link
Member

TimLariviere commented Feb 11, 2019

Sooo... It's a Xamarin.Forms bug finally. :)
The code above is not what Fabulous does.

Fabulous reuses TableView.Root if not null, which is the case by default in Xamarin.Forms.
And for some reasons, this default value ignores property changed events, where a new TableRoot will not.

So I will change the way Fabulous works and raise an issue on the Xamarin.Forms repo.

@TimLariviere
Copy link
Member

@sergey-tihon
Copy link
Author

Thank you @TimLariviere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants