NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

SOLVED: Ultimate Portfolio App: Editing a Project Dismiss immediately

Forums > SwiftUI

RocketSim Recording - iPhone 12 Pro - 2020-11-16 21 06 28

So i try to edit a project in the view created by

And whenever i do a change in the project, insert a new letter in the textField or tap the color. The EditProjectView automatically dismisses.

I'm definitively not sure what went wrong.

In ProjectsView i use the header like:

List {
                ForEach(projects.wrappedValue) { project in
                    Section(header: ProjectHeaderView(project: project)) {

Then the ProjectHeaderView is defined like:

struct ProjectHeaderView: View {
    @ObservedObject var project: Project

    var body: some View {
        HStack {
            VStack(alignment: .leading) {

                ProgressView(value: project.completionAmount)


            NavigationLink(destination: EditProjectView(project: project)) {
                Image(systemName: "square.and.pencil")
        .padding(.bottom, 10)

Finally the EditProjectView starts with code like:

struct EditProjectView: View {
    let project: Project

    @State var title: String
    @State var detail: String
    @State var color: String
    @State var isShowingAlert: Bool = false

    @Environment(\.presentationMode) var presentationMode
    @EnvironmentObject var dataController: DataController

    var colorColumns: [GridItem] = [GridItem(.adaptive(minimum: 44))]

    init(project: Project) {
        self.project = project

        self._title = State(wrappedValue: project.projectTitle)
        self._detail = State(wrappedValue: project.projectDetail)
        self._color = State(wrappedValue: project.projectColor)

    var body: some View {
        Form {
            Section(header: Text("Basic settings")) {
                TextField("Title", text: $title.onChange(update))
                TextField("Description of the project", text: $detail.onChange(update))

I don't get it, has anyone found an issue like this?


I am also having this issue. Were you able to figure it out?

I was able to narrow it down to the update() call being what triggers this issue. Since it updates the Project object, it'll also tell all objects listening for changes to the Project object.

ProjectHeaderView listens to changes on the Project object so it'll recreate its body property. I think this is what causes the EditProjectView to disappear since the ProjectHeaderView is its parent view.


How does you update method look like?


I contacted Paul and he mentioned it was a new bug in iOS 14.2 which he reported to apple.

He also mentioned that:

if you rotate to landscape then back to portrait again it works just fine, or if you use any 14.1 simulator it works fine


It seems to stll be there in 14.4 simulator and on my daily driver 11 Pro Max 14.4.2.


Same with iPhone 12 Pro v14.4 simulator, Xcode 12.4, on Catalina 10.15.7

Rotating the simulator causes immediate dismissal for me - doesn't fix the problem.

I think @Luissh22 is probably right.


@twostraws  Site AdminHWS+

This should be resolved in Xcode 12.5.


Hacking with Swift is sponsored by Instabug

SPONSORED Catch bugs as soon as they happen and know exactly why a crash occurred. Instabug's SDK grabs all the logs they need to fix bugs, crashes and performance issues in minutes instead of days. Get screenshots, device details, network logs, repro steps, and tons of other critical insights needed to resolve issues and prioritize product backlogs straight from your dashboard. It only takes a minute to integrate!

Get started now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.