Skip to content

Commit d528858

Browse files
committed
Fix: TextField gray overlay when iOS app runs on macOS
Issue: When the iOS app is downloaded from the Mac App Store and run on Apple Silicon Macs, a gray overlay appears over TextField components when Increase Contrast accessibility setting is disabled. Reproduction: 1. Download bitchat iOS app from Mac App Store 2. Run on Apple Silicon Mac 3. Disable 'Increase Contrast' in System Settings > Accessibility > Display 4. Focus on text input field - gray overlay appears Fix: Use ProcessInfo.processInfo.isiOSAppOnMac runtime detection to disable autocorrection only when iOS app runs on macOS. This targets the exact environment where the issue occurs while preserving normal autocorrection behavior for iPhone/iPad users. Addresses code review feedback about incorrect conditional compilation.
1 parent 787386c commit d528858

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

bitchat/Views/ContentView.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ import SwiftUI
1111
import UIKit
1212
#endif
1313

14+
#if os(iOS)
15+
@available(iOS 14.0, *)
16+
struct IOSOnMacFixModifier: ViewModifier {
17+
func body(content: Content) -> some View {
18+
if ProcessInfo.processInfo.isiOSAppOnMac {
19+
content
20+
.autocorrectionDisabled(true)
21+
} else {
22+
content
23+
}
24+
}
25+
}
26+
#endif
27+
1428
// MARK: - Supporting Types
1529

1630
//
@@ -815,6 +829,10 @@ struct ContentView: View {
815829
.foregroundColor(textColor)
816830
.focused($isTextFieldFocused)
817831
.padding(.leading, 12)
832+
#if os(iOS)
833+
// Fix for gray overlay issue when iOS app runs on macOS with Increase Contrast disabled
834+
.modifier(IOSOnMacFixModifier())
835+
#endif
818836
// iOS keyboard autocomplete and capitalization enabled by default
819837
.onChange(of: messageText) { newValue in
820838
// Cancel previous debounce timer

0 commit comments

Comments
 (0)