WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

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 https://www.hackingwithswift.com/plus/ultimate-portfolio-app/editing-projects

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.


The bug is still present on iOS 15.2 :/


Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.