From 66711b471e4263801ea3ce012ca1fb0e5af3fc92 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 19 May 2026 04:07:27 +0800 Subject: [PATCH] fix: smooth ios search exit --- ios/App/App/AppDelegate.swift | 31 ++++++++++++++++++++-------- ios/App/App/NativeTopBarPlugin.swift | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index 548e404cf3..d743b50fe4 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -426,20 +426,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel return } - // Fast-path: cancel search -> home root. + // Fast-path: leave SwiftUI search for the Home tab. During this + // transition SwiftUI is already moving the shared nav controller + // back into the Home tab, so rebuilding it here causes UIKit + // transition conflicts. if previousStackId == "search", - stackId == "home", - path == self.rootPath(for: "home") { + stackId == "home" { self.setPaths(["/__stack__/search"], for: "search") self.activeStackId = "home" - self.setPaths(["/"], for: "home") - let vc = NativePageViewController(path: "/") - nav.setViewControllers([vc], animated: false) - self.setViewControllers([vc], for: "home") - SharedWebViewController.instance.clearPlaceholder() - SharedWebViewController.instance.attach(to: vc) + var newPaths = self.paths(for: "home") + if path == self.rootPath(for: "home") { + newPaths = [path] + } else if navigationType == "reset" { + newPaths = [path] + } else if newPaths.isEmpty { + newPaths = [path] + } else if navigationType == "push", + let last = newPaths.last, + last != path { + newPaths.append(path) + } else if let last = newPaths.last, last != path { + newPaths[newPaths.count - 1] = path + } + + self.pathStack = newPaths + self.setPaths(newPaths, for: "home") return } diff --git a/ios/App/App/NativeTopBarPlugin.swift b/ios/App/App/NativeTopBarPlugin.swift index 686c18be46..8a907a72c6 100644 --- a/ios/App/App/NativeTopBarPlugin.swift +++ b/ios/App/App/NativeTopBarPlugin.swift @@ -63,7 +63,7 @@ public class NativeTopBarPlugin: CAPPlugin, CAPBridgedPlugin { return } - nav.setNavigationBarHidden(hidden, animated: true) + nav.setNavigationBarHidden(hidden, animated: false) guard !hidden else { call.resolve() return