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

ListView selected error #14792

Open
HaoLife opened this issue Dec 11, 2023 · 6 comments
Open

ListView selected error #14792

HaoLife opened this issue Dec 11, 2023 · 6 comments
Labels
area/listview 📃 Categorizes an issue or PR as relevant to the ListView control area/mvux Categorizes an issue or PR as relevant to MVU-X difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...)

Comments

@HaoLife
Copy link

HaoLife commented Dec 11, 2023

Current behavior

ListViewBase has issues with invalid or delayed selection in mvux mode


        void SingleSelectionCase()
        {
            if (base.ItemsSource is ICollectionView collectionView)
            {
                collectionView.MoveCurrentToPosition(clickedIndex);
                clickedIndex = collectionView.CurrentPosition;
            }

            if (modifiers.HasFlag(VirtualKeyModifiers.Control) && clickedIndex == base.SelectedIndex)
            {
                base.SelectedIndex = -1;
            }
            else
            {
                base.SelectedIndex = clickedIndex;
            }
        }

// clickedIndex=1
//collectionView.MoveCurrentToPosition(clickedIndex);
// collectionView.CurrentPosition=0
				collectionView.MoveCurrentToPosition(clickedIndex);
				clickedIndex = collectionView.CurrentPosition;

Expected behavior

No response

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

Affected platforms

WebAssembly, Android, iOS, macOS (AppKit), Mac Catalyst, Skia (WPF), Skia (Linux Framebuffer)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@HaoLife HaoLife added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Dec 11, 2023
@jeromelaban
Copy link
Member

Thanks for the report. Can you provide a full sample that reproduces your problem? It will be easier to discuss the original behavior.

@jeromelaban jeromelaban added the triage/needs-information Indicates an issue needs more information in order to work on it. label Dec 11, 2023
@HaoLife
Copy link
Author

HaoLife commented Dec 12, 2023

MainPage.xaml
`

<StackPanel Grid.Row="1"
      HorizontalAlignment="Stretch"
      VerticalAlignment="Stretch"
      Spacing="16">

  <mvux:FeedView Source="{Binding Trends}">
    <DataTemplate>
      <ListView ItemsSource="{Binding Data}" SelectionMode="Single" IsItemClickEnabled="True">
        <ListView.ItemTemplate>
          <DataTemplate>
            <StackPanel Padding="0,10">
              <TextBlock Text="{Binding}" />
            </StackPanel>

          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>
    </DataTemplate>
  </mvux:FeedView>
</StackPanel>

`

`
using System;
using System.Threading;

namespace UnoApp1.Presentation;

public partial record MainModel
{
private INavigator _navigator;
private readonly IDispatcher dispatcher;

public MainModel(
    IStringLocalizer localizer,
    IOptions<AppConfig> appInfo,
    INavigator navigator,
    IDispatcher dispatcher)
{
    _navigator = navigator;
    this.dispatcher = dispatcher;

    Title = "Main";
    Title += $" - {localizer["ApplicationName"]}";
    Title += $" - {appInfo?.Value?.Environment}";
}

public string? Title { get; }

public IState<string> Name => State<string>.Value(this, () => string.Empty);

public async Task GoToSecond()
{
    var name = await Name;
    await _navigator.NavigateViewModelAsync<SecondModel>(this, data: new Entity(name!));
}


//Uno.Extensions.Reactive.Bindings.BindableListFeed<string>
public IListFeed<string> Trends => ListFeed.Async(async (ct) => await this.GetAsync());

public async ValueTask<IImmutableList<string>> GetAsync()
{

    var list = new List<string>() { "test", "456", "7", "8", "9" };

    return list.ToImmutableList();
}

}

`

image
Uploading UnoApp1 (2).zip…

@jeromelaban
Copy link
Member

Thanks. It seems that the repro was not attached properly. To create a repro, make sure to follow this.

@HaoLife
Copy link
Author

HaoLife commented Dec 13, 2023

UnoApp1.zip

@dr1rrb
Copy link
Member

dr1rrb commented Dec 13, 2023

Hey @HaoLife, thanks for the report.

I tried your sample, I'm not sure what is failing? No matter how I use the selection with MVUX, I get the right selected item (even if I try to unselect the item using the CTRL key).

@HaoLife
Copy link
Author

HaoLife commented Dec 16, 2023

It needs to constantly switch between selected items, which may lag or become ineffective when replaced frequently

https://github.com/unoplatform/uno/assets/25171162/f0647b02-721a-4a61-842a-43dafc87bb0b

1702740136370

@MartinZikmund MartinZikmund changed the title ListView selected error ListView selected error Jan 29, 2024
@MartinZikmund MartinZikmund added project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...) difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI area/mvux Categorizes an issue or PR as relevant to MVU-X and removed triage/needs-information Indicates an issue needs more information in order to work on it. triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jan 29, 2024
@MartinZikmund MartinZikmund added the area/listview 📃 Categorizes an issue or PR as relevant to the ListView control label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/listview 📃 Categorizes an issue or PR as relevant to the ListView control area/mvux Categorizes an issue or PR as relevant to MVU-X difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...)
Projects
None yet
Development

No branches or pull requests

4 participants