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

[Wasm] Default selected items from ItemsRepeaterExtensions multiselection are unselectable on the first click #1194

Closed
16 tasks
rajamatt opened this issue Jun 20, 2024 · 9 comments · Fixed by #1212
Assignees
Labels
control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag kind/bug Something isn't working

Comments

@rajamatt
Copy link
Contributor

rajamatt commented Jun 20, 2024

Current behavior

Setup: ItemsRepeater with utu:ItemsRepeaterExtensions.SelectionMode="Multiple" with items selected by default.
Problem: Makes selected items that are selected by default when loading the page unselectable on the first click.

This sample is using a ListViewItem as the ItemsRepeater's ContentTemplate, but it also happens with other selection controls such as ToggleButton.

Here, the item "two" is selected by default when opening the app:
ListViewItemsRepeater

Minimal repro app: ItemsRepeaterSelection.zip

Expected behavior

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

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

  • iOS
  • macOS (AppKit)
  • Mac Catalyst
  • Android
  • WebAssembly
  • Windows
  • Skia (WPF)
  • Skia (GTK on Linux/macOS/Windows)
  • Skia (Linux Framebuffer)
  • Build tasks

Visual Studio:

  • 2019 (version: )
  • 2022 (version: )
  • Visual Studio Code (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

@rajamatt rajamatt added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Jun 20, 2024
@kazo0 kazo0 transferred this issue from unoplatform/uno.extensions Jul 15, 2024
@kazo0
Copy link
Contributor

kazo0 commented Jul 15, 2024

@Kunal22shah I believe this is the same root issue that we were discussing with the itemsrepeater, I will link this as the blocker for that issue in the backlog

@kazo0 kazo0 removed the triage/untriaged Indicates an issue requires triaging or verification. label Jul 15, 2024
@dr1rrb
Copy link
Member

dr1rrb commented Jul 18, 2024

Could be either the Toolkit's ItemsRepeaterExtensions which does not restore the initial/current selection when the collection is data-bound, either MVUX which pushes that initial selection with a delay (as ISelectionInfo does not provided any way to update teh selection from the source to the view, the selection has to be sync)

@rajamatt rajamatt self-assigned this Jul 18, 2024
@Xiaoy312 Xiaoy312 self-assigned this Jul 18, 2024
@Xiaoy312
Copy link
Contributor

the data came with desync'd states:
image
^ GetSelectedRanges just returns empty array of ItemIndexRange

you can even repro it without toolkit:

public MainPage()
{
	this.InitializeComponent();
	SUT.RegisterPropertyChangedCallback(ItemsRepeater.ItemsSourceProperty, IR_ItemsSourceChanged);
	this.DataContext = new BindableMainModel();
}
private void IR_ItemsSourceChanged(DependencyObject sender, DependencyProperty dp)
{
	if (sender is not ItemsRepeater ir) return;
	if (ir.ItemsSource is ISelectionInfo si)
	{
			var ranges = si.GetSelectedRanges(); // new ItemIndexRange[0]
			var rangesDebug = string.Join(", ", ranges.Select(x => x.Length > 1 ? $"[{x.FirstIndex}-{x.LastIndex}]" : $"[{x.FirstIndex}]"));

			var isSelecteds = Enumerable.Range(0, (si as BindableListFeed<string>)?.Count ?? 0)
				.Select(si.IsSelected)
				.ToArray(); // false, true, false
	}
}

@dr1rrb
Copy link
Member

dr1rrb commented Jul 19, 2024

@Xiaoy312 Is this on windows?

@Xiaoy312 Xiaoy312 added the control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag label Jul 26, 2024
@kazo0
Copy link
Contributor

kazo0 commented Jul 26, 2024

@rajamatt I see there is a draft PR for this that is Windows-specific. This issue is also occurring on WASM no?

@rajamatt
Copy link
Contributor Author

@kazo0 Yes the Wasm problem is in toolkit, I didn't get the chance to finalize the Wasm changes yet

@kazo0
Copy link
Contributor

kazo0 commented Jul 26, 2024

Wasm problem is in toolk

@rajamatt whats the issue in toolkit? do we have a separate issue for that? We can split these issues if they are different problems

@rajamatt
Copy link
Contributor Author

rajamatt commented Jul 26, 2024

@kazo0 Yeah both repos produce the same bug but for different reasons,

On Windows in uno.extensions it's because we weren't setting the _localSelection when constructing. On Wasm in uno.toolkit.ui it's because there's some delay, the ItemsRepeater.ItemsSource is populated with empty data and then populated after a certain delay with the real data. Binding instead to ItemsRepeater.ItemsSourceView.CollectionChanged fixes this (I wish I had some code to show but my branch is a bit broken right now)

Let me know if I should create a separate issue

@kazo0
Copy link
Contributor

kazo0 commented Jul 29, 2024

@rajamatt yes let's create a separate issue and we can edit this one for the Windows specific scenario. Reach out to @Xiaoy312 and I if you need input on the fix for the ItemsRepeater one

@kazo0 kazo0 changed the title [Windows/Wasm] Default selected items from ItemsRepeaterExtensions multiselection are unselectable on the first click [Windows] Default selected items from ItemsRepeaterExtensions multiselection are unselectable on the first click Jul 29, 2024
@rajamatt rajamatt changed the title [Windows] Default selected items from ItemsRepeaterExtensions multiselection are unselectable on the first click [Wasm] Default selected items from ItemsRepeaterExtensions multiselection are unselectable on the first click Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants