TabbedPage with ToolbarPlacement = Bottom: SelectedTabColor does not move highlight to correct tab if the tab is changed programmatically #18558
Labels
area-controls-tabbedpage
TabbedPage
migration-compatibility
Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert
platform/android 🤖
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
Description
In a .NET 7 Maui app on Android, if you have a TabbedPage with the tab bar located at the bottom of the page, and you change the current page during a Handler-mapped page changing event method or an OnCurrentPageChanged event handler, the SelectedTabColor highlight will not move to the new CurrentPage, but will instead stay on the actual tab selected (tapped) by the user.
In my application, we have user-level permissions which can block certain tabs from being accessed. We check these permissions in a TabbedViewHandler-derived class:
In the BlockIfNeeded method, we check the user's permissions, and if they're denied access, we send them back to their most recent tab. We've tried several different methods of changing the active tab (setting SelectedItem, setting CurrentPage, going into the underlying platform view and calling SetCurrentItem, etc.); in each of these cases, the actual selected tab is updated correctly, but the bottom tab bar continues to highlight the previous (inaccessible) tab.
Steps to Reproduce
Expected result: Page 1 is activated, and the tab for Page 1 gets the SelectedTabColor highlight. All other tabs have the UnselectedTabColor highlight.
Actual result: Page 1 is activated, and the tab for Page 2 gets the SelectedTabColor highlight. All other tabs have the UnselectedTabColor highlight.
Link to public reproduction project repository
https://github.com/mcmcelro/SelectedTabColorBug
Version with bug
7.0.100
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
All compatible Android versions
Did you find any workaround?
No.
In Xamarin.Forms, this was handled using a Renderer which derived from
TabbedPageRenderer
andNavigationBarView.IOnItemSelectedListener
. The methodbool NavigationBarView.IOnItemSelectedListener.OnNavigationItemSelected(IMenuItem item)
would prevent the highlight from moving to the new tab iffalse
was returned. We have yet to find a way to implement this in Maui.Relevant log output
The text was updated successfully, but these errors were encountered: