How can you dismiss the new ColorPicker?

Given the following code, how can you dismiss the ColorPicker in live previews or in the simulator? Currently, the ColorPicker displays fine, allows me to select different colors, but I cannot figure out how to dismiss it.

Code Block import SwiftUI
struct ContentView: View {
    @State private var bgColor = Color.white
    
    var body: some View {
        VStack {
            ColorPicker("Color picker", selection: $bgColor)
        }
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ContentView()
        }
    }
}


I have the same problem, I'm not able to dismiss it
I have the same problem, but just on iPhone.
This is a known issue.
How to dismiss it?
I don't think it is possible to do that in the latest updates.
You can create a UIViewControllerRepresentable and add this following stub:

Code Block
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
            self.colorPick.colors =  viewController.selectedColor
              viewController.dismiss(animated: true, completion: nil)
            }
        }


This dismisses the sheet right after a color selection. You can add a do - usleep function to add a slight delay after the color selection so that the user has an opportunity to change the color. I am looking into setting up a gesture instead of this method.
I think this might be fixed in Xcode 12.3 Beta. I ran the code in the live preview and in the simulator, and I am able to hit the close button on the upper right corner to close the ColorPicker and have the selected color outside that view.
Neither do I, i can't dismiss it!
How can you dismiss the new ColorPicker?
 
 
Q