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

[droid] Toggling NV.IsBackButtonVisible prevents NVIs expansion/collapse from updating their layout #19516

Open
Xiaoy312 opened this issue Feb 13, 2025 · 0 comments · May be fixed by #19517
Open
Labels
area/items-repeater Categorizes an issue or PR as relevant the ItemsRepeater control area/navigationview 🧭 Categorizes an issue or PR as relevant to the NavigationView control difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)

Comments

@Xiaoy312
Copy link
Contributor

Xiaoy312 commented Feb 13, 2025

Current behavior

Image
^ after changing NavView::IsBackButtonVisible value, all NVItems would stop updating their layout/size when expanded/collapsed.

Expected behavior

^ should not happen

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

uno runtime test snippet
[TestMethod]
public async Task When_AsdAsd02()
{
	var sut = new MUXC.NavigationView()
	{
		Height = 500,
		IsBackButtonVisible = MUXC.NavigationViewBackButtonVisible.Collapsed,
		IsPaneToggleButtonVisible = false,
		PaneDisplayMode = NavigationViewPaneDisplayMode.Left,
		CompactModeThresholdWidth = 10,
		ExpandedModeThresholdWidth = 50,
	};
	sut.ItemInvoked += (s, e) =>
	{
		// manual trigger for deepest/inner-most items
		if (e.InvokedItemContainer is NavigationViewItem nvi &&
			nvi.MenuItems.Count == 0)
		{
			sut.IsBackButtonVisible = NavigationViewBackButtonVisible.Visible;
		}
	};

	var nvis = new Dictionary<string, NavigationViewItem>();
	//AddItems(sut.MenuItems, "", count: 4, depth: 1, maxDepth: 2);
	AddItems(sut.MenuItems, "", count: 3, depth: 1, maxDepth: 3);
	void AddItems(IList<object> target, string prefix, int count, int depth, int maxDepth)
	{
		for (int i = 0; i < count; i++)
		{
			var header = prefix + (char)('A' + i);
			var item = new NavigationViewItem() { Content = header };

			if (depth < maxDepth) AddItems(item.MenuItems, header, count, depth + 1, maxDepth);

			target.Add(item);
			nvis.Add(header, item);
		}
	}

	// for debugging
	var panel = new StackPanel();
	void AddTestButton(string label, Action action)
	{
		var button = new Button() { Content = label };
		button.Click += (s, e) => action();
		panel.Children.Add(button);
	}
	AddTestButton("InvalidateMeasure", () => sut
		.EnumerateDescendants().OfType<ItemsRepeater>()
		.ForEach(x => x.InvalidateMeasure()));
	AddTestButton("IsBackButtonVisible toggle", () => sut.IsBackButtonVisible = sut.IsBackButtonVisible == NavigationViewBackButtonVisible.Collapsed
		? NavigationViewBackButtonVisible.Visible
		: NavigationViewBackButtonVisible.Collapsed);
	panel.Children.Add(sut);

	await UITestHelper.Load(panel, x => x.IsLoaded);
}
  1. run the test on android target
  2. expand 'B' and then 'BB'
  3. click on 'BBB' or 'IsBackButtonVisible toggle' to trigger the bug
  4. expand/collapse any nvi
    ^ notice that no longer push or pull the items around

Workaround

invoke InvalidateMeasure on all nested ItemsRepeaters

Works on UWP/WinUI

No

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

[email protected] AND uno @ 9252761

Affected platforms

Android

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

ref: https://github.com/unoplatform/ziidms-private/issues/46

@Xiaoy312 Xiaoy312 added area/items-repeater Categorizes an issue or PR as relevant the ItemsRepeater control area/navigationview 🧭 Categorizes an issue or PR as relevant to the NavigationView control difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..) labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/items-repeater Categorizes an issue or PR as relevant the ItemsRepeater control area/navigationview 🧭 Categorizes an issue or PR as relevant to the NavigationView control difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant