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

SOLVED: Update forces view to be dismissed (bug or error?) - UltimatePortfolio: Editing projects

Forums > Articles

I just completed the "Editing projects" article from the UltimatePortfolio series and I'm noticing a bug when I attempt to make any chnages in the EditProjectView. Each time I attempt to make any state change the view is immediately dismissed and I jump back to the ProjectsView. Example

This seems to specifically happen when the update() function is called. My update() function is identical to Paul's.

func update() {
        project.title = title
        project.detail = detail
        project.color = color
    }

So far I think it's related to the fact that the project property in the parent view (ProjectHeaderView) uses the @ObservedObject property wrapper. It seems that when the project property in the parent ProjectHeaderView updates, the EditProjectView within the NavigationLink gets dismissed. Is anyone else having this issue? It doesn't seem to happen in Paul's video. I've gone through and I don't see any obvious discrepencies between my code and Paul's.

What am I missing?

   

So it looks like this was specifically a bug with the latest Xcode 12.2 Beta. It's working correctly on the Xcode 12.1 release

2      

@twostraws  Site AdminHWS+

Oh lovely. Please file some feedback with Apple – this might actually ship into production, and it's quite a breaking change!

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Building and maintaining in-app subscription infrastructure is hard. Luckily there's a better way. With RevenueCat, you can implement subscriptions for your app in hours, not months, so you can get back to building your app.

Try it for free

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

I just sent an email to Paul about this. I thought it was an issue with the code from the latest lesson (adding/deleting).

It only occurs when there's two or more projects and works as intended with only one project.

   

Thank you for the 'heads up'. I was going around in circles trying to get this to work (beta version), rolled back to 12.1 release and all works as it should!

   

Was also stumped by this for a while in 12.2 beta 3, glad I came across this post! Thank you, will also file some feedback!

   

This was driving me nuts as well and I was thinking I'd introduced a bug somewhere random! Thanks for finding the issue.

Xcode 12.2 beta 4 (RC) seems to have resolved the issue - good job, otherwise we'd be pushing back on that version :-)

   

Well, I'm late to the party, but I got the same bug in Xcode 12.2 (non-beta)

Did anyone figure out something that really solves that bug/problem?

   

It seems to be fixed in Xcode 12.3 beta (12C5020f)

   

Not working here on latest beta.

   

Same bug here with Xcode 12.2 on Catalina 10.15.7. Editing items is fine but making any edit to a Project causes the instance of EditProjectView to be dismissed as soon as the handler is called.

   

This bug still exists in Xcode 12.3

   

Bug is still an issue with Xcode 12.3(12C33)

1      

I am still able to recreate the bug consistently with the latest Xcode, as well. I'm working around the bug with the following line. It solves the issue enough for me, but negates the use of the onChange() extension.

TextField("Project name", text: $title, onEditingChanged: { if !$0 { update() } })

The following also works, but requires return to be pressed.

TextField("Project name", text: $title, onCommit: update)

   

Has anyone a fix for this? It's still there with Xcode 12.4.

   

It appears to be fixed once again in 12.5 beta (12E5220o).

   

great

   

Hacking with Swift is sponsored by RevenueCat

SPONSORED Building and maintaining in-app subscription infrastructure is hard. Luckily there's a better way. With RevenueCat, you can implement subscriptions for your app in hours, not months, so you can get back to building your app.

Try it for free

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.