diff --git a/CHANGELOG.md b/CHANGELOG.md index 30772394..5505604b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ #endif ``` * Custom location snapping in the `RouteController` via the delegate +* Fix: Broken layout due to keyboard presentation after changing styles or presenting a second MapView + * Merged in ## 3.0.0 (Jun 15, 2024) * The `speak` method in `RouteVoiceController` can be used without a given `RouteProgress` or the `RouteProgress` can explicitly ignored so that it will not be added to the voice instruction. diff --git a/MapboxNavigation/StyleManager.swift b/MapboxNavigation/StyleManager.swift index 1a681d02..8a3fc627 100644 --- a/MapboxNavigation/StyleManager.swift +++ b/MapboxNavigation/StyleManager.swift @@ -180,7 +180,8 @@ open class StyleManager: NSObject { } func refreshAppearance() { - for window in UIApplication.shared.windows { + // re-adding the keyboard window views can break layout. See https://github.com/maplibre/maplibre-navigation-ios/issues/50 + for window in UIApplication.shared.applicationWindows { for view in window.subviews { view.removeFromSuperview() window.addSubview(view) @@ -233,3 +234,14 @@ extension Solar { } } } + +extension UIApplication { + var applicationWindows: [UIWindow] { + windows.filter { window in + let className = String(describing: type(of: window)) + return !className.contains("UIRemoteKeyboardWindow") && + !className.contains("UITextEffectsWindow") && + !className.contains("UIAlertController") + } + } +}