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

[Android] Fix crash trying to update a removed tab menu item #14661

Merged
merged 1 commit into from
Jan 12, 2022

Conversation

jsuarezruiz
Copy link
Contributor

Description of Change

In #11301 clearing the pages was invoking this code https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs#L540 also in the removed page. Trying to update and get the item, the index does not fit with the collection count.

Added some validations to svoid update the items title or icon if, the index is out of range.

Issues Resolved

API Changes

@@ -537,13 +537,19 @@ void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)

if (IsBottomTabPlacement)
{
IMenuItem tab = _bottomNavigationView.Menu.GetItem(index);
tab.SetTitle(page.Title);
if (_bottomNavigationView.Menu.Size() > index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be just >? For all the checks here? Does it then also work for the last tab? Maybe we should add a test page for this?

Copy link
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this fixes the initial problem. Nice job Javier virtual high-five!

@jfversluis jfversluis merged commit e7c1020 into 5.0.0 Jan 12, 2022
@jfversluis jfversluis deleted the fix-11301 branch January 12, 2022 13:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] TabbedPage on Android: Bottom navigation with more than 5 entries causes IndexOutOfBoundsException on clearing
2 participants