From 4c16e81db5ab6cab0d4e0c90c213767383d73616 Mon Sep 17 00:00:00 2001 From: Manuel Auer Date: Fri, 16 Oct 2026 14:37:01 +0200 Subject: [PATCH] fix(ios): restore panel buttons after leaving pan mode with a panel shown While a map panel was on screen, MapTemplate._invalidate() skipped applying buttons entirely, so dismissing the panning interface left the pan-mode header and map buttons behind. Hand the buttons back to the topmost panel instead, keeping the rule that a panel owns the bar/map buttons while it exists. Co-Authored-By: Claude Opus 5.5 --- .../ios/templates/MapTemplate.swift | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/react-native-autoplay/ios/templates/MapTemplate.swift b/packages/react-native-autoplay/ios/templates/MapTemplate.swift index b8fe5fbe..a568b87e 100644 --- a/packages/react-native-autoplay/ios/templates/MapTemplate.swift +++ b/packages/react-native-autoplay/ios/templates/MapTemplate.swift @@ -145,27 +145,30 @@ class MapTemplate: AutoPlayHeaderProviding, return } - // A panel owns the bar buttons while it exists; keep barButtons up to date but don't apply it. - let hasPanel: Bool = { - if #available(iOS 27.0, *) { - return SceneStore.getRootScene()?.interfaceController?.hasPanel ?? false + // A panel owns the bar and map buttons while it exists; keep barButtons/mapButtons up to date + // but don't apply them. Hand the buttons back to the topmost panel instead, since leaving + // the panning interface (or a trait change) would otherwise leave stale buttons behind. + if #available(iOS 27.0, *), + let topPanelId = SceneStore.getRootScene()?.interfaceController?.panelTemplateIds.last + { + try? RootModule.withAutoPlayTemplate(templateId: topPanelId) { + (panel: AutoPlayTemplate) in + reapplyPanelBarIfVisible(panel, templateId: topPanelId) } - return false - }() + return + } - if !hasPanel { - // Restore CarPlay's default auto-hide (disabled while a panel is shown, see panelDidShow). - template.automaticallyHidesNavigationBar = true - template.hidesButtonsWithNavigationBar = true + // Restore CarPlay's default auto-hide (disabled while a panel is shown, see panelDidShow). + template.automaticallyHidesNavigationBar = true + template.hidesButtonsWithNavigationBar = true - setBarButtons(template: template, barButtons: barButtons) + setBarButtons(template: template, barButtons: barButtons) - if let mapButtons = mapButtons { - template.mapButtons = Parser.parseMapButtons( - mapButtons: mapButtons, - onPanButtonPress: onPanButtonPress - ) - } + if let mapButtons = mapButtons { + template.mapButtons = Parser.parseMapButtons( + mapButtons: mapButtons, + onPanButtonPress: onPanButtonPress + ) } }