fix: only fire browserClosed when the custom tab actually terminates#58
Open
OS-ruimoreiramendes wants to merge 4 commits into
Open
fix: only fire browserClosed when the custom tab actually terminates#58OS-ruimoreiramendes wants to merge 4 commits into
OS-ruimoreiramendes wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactor the Custom Tabs flow so
browserClosedfires only when the Custom Tab actually terminates. UsesActivityResultLauncherinOSIABCustomTabsControllerActivityinstead of inferring closure fromTAB_HIDDENinOSIABCustomTabsSessionHelper.Files changed:
OSIABCustomTabsControllerActivity— registersActivityResultLauncher, launches the CCT from an intent extra, finishes only on the launcher result. Start animations preserved viaActivityOptionsCompat.makeCustomAnimationreconstructed from extras (exit animations travel inside the intent).OSIABCustomTabsRouterAdapter— builds the CCT intent up front and hands it to the controller activity; listens forEVENT_CUSTOM_TABS_DESTROYEDto fireonBrowserFinished.OSIABCustomTabsSessionHelper— removed theTAB_HIDDENinterpretation and theisCustomTabsActivityOnTop/pendingTabHiddenEventstate. Only handlesNAVIGATION_FINISHED → BrowserPageLoaded.Context
CustomTabsCallback.onNavigationEvent(TAB_HIDDEN)fires on close, PiP minimize, home button, task switch — the previous heuristic couldn't disambiguate them and firedbrowserClosedprematurely (notably on PiP).Same approach as
@capacitor/browser#2561, which fixed the equivalent issue in capacitor-plugins#2554.Type of changes
Tests
Unit tests updated to match the new event flow.
Manually tested on a physical Android device using the example app of
capacitor-os-inappbrowser, which uses an AAR of this PR:only on close
Checklist