Xamarin.forms: [Bug] Invalid TabBar.Items access in iOS ShellItemRenderer

Created on 13 May 2019  路  4Comments  路  Source: xamarin/Xamarin.Forms

Description

iOS ShellItemRenderer accesses TabBar.Items to enable / disable items. If there are more shell sections than maxTabs, it could lead to an index out of range exception because they are aggregated in a single "show more" item.

Steps to Reproduce

  1. Create shell project
  2. Create additional shell sections
  3. Set shell section to IsEnabled false to trigger array access
  4. Start app
<!-- Your Pages -->
<ShellItem>
    <ShellSection Title="Browse" Icon="tab_feed.png">
        <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
    </ShellSection>
    <ShellSection Title="About" Icon="tab_about.png">
        <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
    </ShellSection>
    <ShellSection Title="Browse" Icon="tab_feed.png">
        <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
    </ShellSection>
    <ShellSection Title="About" Icon="tab_about.png">
        <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
    </ShellSection>
    <ShellSection Title="Browse" Icon="tab_feed.png">
        <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
    </ShellSection>
    <ShellSection Title="About" Icon="tab_about.png">
        <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
    </ShellSection>
    <ShellSection Title="Browse" Icon="tab_feed.png">
        <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
    </ShellSection>
    <ShellSection Title="About" Icon="tab_about.png" IsEnabled="False">
        <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
    </ShellSection>
</ShellItem>

Expected Behavior

No exception. You might also have to fiddle with the UIMoreNavigationController to disable particular items there.

Actual Behavior

Exception.

4.0.0 shell blocker 2 help wanted high in-progress iOS 馃崕 bug up-for-grabs

Most helpful comment

@pictos Yes!!

All 4 comments

@Dresel Can you please attach a small project that demonstrates this issue? Thanks!

Repo6184.zip

As mentioned, crashes here.

This still happens, so @samhouts can I work on this issue?

@pictos Yes!!

Was this page helpful?
0 / 5 - 0 ratings