Issue #779

With Xcode 12.4, macOS 11.0 app. Every time we switch the system dark and light mode, the CPU goes up to 100%. Instruments show that there’s an increasing number of ButtonBehavior

Suspect State in a row in LazyVStack

Every cell has its own toggle state

struct Cell: View {
    enum ToggleState {
        case general
        case request
        case response
    }

    let item: Item
    @State
    private var toggleState: ToggleState = .general

    func toggleButton(text: String, state: ToggleState) -> some View {
        Button(action: { self.toggleState = state }) {
            Text(text)
                .foregroundColor(state == toggleState ? Color.label : Color.secondary)
                .fontWeight(state == toggleState ? .bold : .regular)
        }
        .buttonStyle(BorderlessButtonStyle())
    }
}

Removing the buttons fix the problem. The workaround is to use Text with onTapGesture

Text(text)
    .foregroundColor(state == toggleState ? Color.label : Color.secondary)
    .fontWeight(state == toggleState ? .bold : .regular)
    .onTapGesture {
        self.toggleState = state
    }