Skip to content

Add alert for deleting a product category - #20

Open
ElisaKazan wants to merge 2 commits into
mainfrom
ek/delete-alert
Open

Add alert for deleting a product category#20
ElisaKazan wants to merge 2 commits into
mainfrom
ek/delete-alert

Conversation

@ElisaKazan

Copy link
Copy Markdown
Owner

Added an alert dialog when deleting a product category. This gives us an extra layer of protection since it will also delete all of the products in the category.

Screenshots

Tried a Confirmation Dialog but didn't like how it looked.

.onDelete(perform: removeCategory)
.onDelete { indexSet in
deletedIndexSet = indexSet
showingDeleteAlert = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is the issue, changing 2 state properties. A change to a state prop tells the view to re-render. Somehow this is causing the showingDeleteAlert to get set to false. I wonder what the solution is

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crazy question, I wonder if reversing these makes a difference

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StackOverflow says this works, but it is hacky
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
showingDeleteAlert = true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants