Fabulous: macOS: TableView group name does not update

Created on 7 Feb 2019  路  7Comments  路  Source: fsprojects/Fabulous

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

bug

All 7 comments

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.

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.

The issue is also present on iOS and Android.

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();
    }
}

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.

For those interested, here's the 2 issues I've raised on Xamarin.Forms:

Thank you @TimLariviere

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JordanMarr picture JordanMarr  路  6Comments

Happypig375 picture Happypig375  路  3Comments

SergejDK picture SergejDK  路  5Comments

johannesegger picture johannesegger  路  6Comments

Happypig375 picture Happypig375  路  4Comments