Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] ShellItem.Items.Clear() crashes when the ShellItem has bottom tabs #6878

Closed
SFSteve opened this issue Jul 15, 2019 · 7 comments
Closed
Labels
a/shell 🐚 e/1 🕐 1 hacktoberfest 🍻 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! t/bug 🐛

Comments

@SFSteve
Copy link

SFSteve commented Jul 15, 2019

Description

When using shell, if you want to programmatically clear and redraw the bottom tabs on a shell page, you can't use Items.Clear to get rid of all the existing ones because it crashes. Investigation suggests that this is because it's trying to set properties on a tab that is no longer there.

Steps to Reproduce

  1. Create a ShellItem in xaml that contains tabs.
  2. In code, call Items.Clear() on your ShellItem.
  3. A null exception will occur on line 83 of ShellBottomNavViewAppearanceTracker.SetBackgroundColor, presumably because menuView.GetChildAt(index) returns null, either because index is -1 or menuView has no children.

Expected Behavior

The tabs are cleared and you're free to create new ones

Actual Behavior

Exception and crash

Basic Information

  • Version with issue: 4.0.0.425677
  • Last known good version: Unknown
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:
    • iOS: Untested
    • Android: 9.0
@SFSteve SFSteve added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 15, 2019
@jsuarezruiz
Copy link
Contributor

Do you have a sample where the problem happens?, could you attach it?. Thanks in advance!

@jsuarezruiz jsuarezruiz added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. and removed s/unverified New report that has yet to be verified labels Jul 16, 2019
@SFSteve
Copy link
Author

SFSteve commented Jul 17, 2019

https://github.com/SFSteve/Xamarin-Demos/tree/master/Xaminals

If you run that then go to the Random page from the flyout menu, you'll get the error.

@francis2
Copy link

If it helps, here is another test app to demonstrate the issue.

The crash happens at AppShell.xaml.cs line 29.

PickerTestApp.zip

@PureWeen
Copy link
Contributor

PureWeen commented Jul 18, 2019

Edit

Adding an exception is probably not the best solution for this
See comment here
#8079 (comment)

Edit over

Most likely the fix for this will be to just throw an exception that Clear isn't supported for Shell

If you clear all the items then Shell has no idea what to display. It's like setting the MainPage on the app to NULL

We have work being done for an IsVisible property which will be the way to change visibility of items. For now I would just add what you are wanting to add then remove what you are wanting to remove

@SFSteve
Copy link
Author

SFSteve commented Jul 18, 2019

An IsVisible flag would be ideal and solve the actual issue we're having, so it's good to know there's one on the way.

@samhouts samhouts added a/shell 🐚 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often s/unverified New report that has yet to be verified and removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Jul 18, 2019
@samhouts samhouts added e/1 🕐 1 and removed s/unverified New report that has yet to be verified labels Jul 18, 2019
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Oct 18, 2019
@samhouts
Copy link
Member

samhouts commented Dec 6, 2019

closed by #8215

@samhouts samhouts closed this as completed Dec 6, 2019
@minahenin
Copy link

minahenin commented Dec 14, 2019

Hi, This is still broken in IOS, any plans on when this will be fixed?

even when the Tab has multiple ShellItems when I try to Remove the first item "Items.RemoveAt(0);" it still crashes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/shell 🐚 e/1 🕐 1 hacktoberfest 🍻 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! t/bug 🐛
Projects
None yet
6 participants