Button text is invisible after dark/light mode change

I'm working on a macOS SwiftUI app. I notice that Button text does not change color properly when the app changes between Dark and Light mode. Shouldn't the builtin Button be handling this automatically? The Text views seem to handle it fine and switch their text from white to black.

The Button text can become completely invisible when I go from Dark to Light mode. Restarting the app fixes it.

I can change the Dark/Light mode manually in System preferences, or it changes at certain times of day because I have it set, usually, to "Auto".




Replies

Could you provide some code so I can better understand how you’re using Button?
JoshATA, It appears that the HSplitView is causing it. If you run the following, and change light to dark or vice versa in System Preferences, you see the "Test" button behave badly.

Code Block
struct ContentView: View {
    var body: some View {
        HSplitView {           
            VStack {
                Text("Does this button change color correctly?")
                Button("Test") {
                    print("Hi.")
                }
            }
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity)
    }
}

tested your code but could not replicate your issue, with or without the HSplitView.
All seems to work with xcode 12.5 beta, macos 11.3 beta.
Hi "workingdogintokyo", Thanks for taking the time to do that. I'm running the newest non-beta stuff: macOS 11.2.1 and Xcode 12.4. So maybe that's the difference, and they've fixed it in the new versions.

One other thing I didn't mention: I checked "SwiftUI App" when creating my test project, not "AppKit App Delegate". Other than that I changed nothing, besides the ContentView code I posted.

I may also try a system restart. My MacBook's current "uptime" is 36 days.
Hi rnikander, I tested the code again starting from dark mode going to light mode, and I'm getting your issue. The "Test" word in the button does not initially show up. It does once I click on it, but if another panel/window goes on top, it disappear again.
I think it's a bug.
Okay, good to know. If I go from light to dark, I get text that while not invisible, is still colored wrong (not enough contrast).
I reported a bug. FB9049107.