Skip to content

[.Net10][Proposal]TabbedPage - TabActiveTapped event #30445

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

Open
wants to merge 2 commits into
base: net10.0
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jul 5, 2025

Description of Change
This proposal introduces a new TabReselected event to the .NET MAUI TabbedPage. This event is raised when a user taps on the currently active tab. It provides developers with a clean and consistent way to handle tab reselection scenarios across platforms.

Motivation
In many tab-based applications, it's a common user expectation that tapping an already selected tab performs an action, such as popping the navigation stack to the root or refreshing the content. Currently, developers must implement workarounds to detect tab reselection, which adds complexity and platform-specific code.

Fixes #27401
Fixes #15301
Fixes #29395

@Copilot Copilot AI review requested due to automatic review settings July 5, 2025 17:24
@kubaflo kubaflo requested a review from a team as a code owner July 5, 2025 17:24
@kubaflo kubaflo self-assigned this Jul 5, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 5, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new TabReselected event to TabbedPage so that taps on the currently active tab can be handled consistently across platforms.

  • Adds the TabReselected event and an OnTabReselected invoker in the shared TabbedPage class.
  • Hooks into Android’s TabbedPageManager and iOS’s compatibility TabbedRenderer to raise the event on reselection.
  • Updates PublicAPI.Unshipped.txt for all frameworks to expose the new event.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

File Description
src/Controls/src/Core/TabbedPage/TabbedPage.cs Added TabReselected event and OnTabReselected method
src/Controls/src/Core/Platform/Android/TabbedPageManager.cs Invoke OnTabReselected on bottom‐nav and tab reselection
src/Controls/src/Core/Compatibility/Handlers/TabbedPage/iOS/TabbedRenderer.cs Override ViewDidLoad to wire up tab reselection callback
src/Controls/src/Core/PublicAPI/**/PublicAPI.Unshipped.txt Expose TabbedPage.TabReselected in public API for each TF
Comments suppressed due to low confidence (3)

src/Controls/src/Core/TabbedPage/TabbedPage.cs:62

  • Missing XML documentation for the TabReselected event; please add a <summary> explaining its purpose.
		public event EventHandler TabReselected;

src/Controls/src/Core/TabbedPage/TabbedPage.cs:62

  • No tests were added for TabReselected; please add UI tests in TestCases.HostApp and corresponding NUnit tests in TestCases.Shared.Tests to validate the event is raised.
		public event EventHandler TabReselected;

src/Controls/src/Core/Platform/Android/TabbedPageManager.cs:968

  • [nitpick] The field _initialBottomNavigation is a bit ambiguous; consider renaming to _hasInitialNavigationSelection or _isFirstNavigationTap for clarity.
			bool _initialBottomNavigation;

@kubaflo kubaflo changed the title [.Net10][Proposal]TabbedPage - TabReselected event [.Net10][Proposal]TabbedPage - TabActiveTapped event Jul 7, 2025
@rmarinho
Copy link
Member

rmarinho commented Jul 8, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

base.ViewDidLoad();
ShouldSelectViewController = (tabController, viewController) =>
{
if (viewController == tabController.SelectedViewController)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (viewController == tabController.SelectedViewController)
if (viewController is tabController.SelectedViewController)

Copy link
Member

Choose a reason for hiding this comment

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

I m confused this is ShouldSelectViewController and we use that to send an event that we activated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because it always returns true

Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

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

We normally don t add public api to service release.

Can we make that internal for now?

Also we might need to add some comments to better understand why we have the state _initialBottomNavigation

@kubaflo
Copy link
Contributor Author

kubaflo commented Jul 10, 2025

@rmarinho sorry my bad... this PR should be targeted to net10 only

Also I've added such comment

// The _initialBottomNavigation flag prevents TabActiveTapped from firing during initial setup.
// We only want this event when users actually tap an already-selected tab, not during framework initialization.

@kubaflo kubaflo changed the base branch from main to net10.0 July 10, 2025 22:46
@kubaflo kubaflo force-pushed the TabbedPage---TabReselected-event branch from 629fe75 to 2c913e9 Compare July 10, 2025 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants