Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug on delete list #79

Merged
merged 5 commits into from
May 22, 2024
Merged

fix bug on delete list #79

merged 5 commits into from
May 22, 2024

Conversation

ocsiddisco
Copy link
Collaborator

Description

When deleteing a list, the modal did not close and stayed in loading state.

Type of Changes

Bug fix

Updates

Before

BugDeleteDespiensa

After

FixBugDeleteDespiensa

Testing Steps / QA Criteria

Note: I am encountering issue with the new firebase config and can't loggin to the app. You may encounter the same issue and may not be able to test it right away.
(I worked on the bug, with the previous config)

  • pull ce-bugDelete
  • delete a list

@ocsiddisco ocsiddisco self-assigned this May 3, 2024
Copy link

github-actions bot commented May 3, 2024

Visit the preview URL for this PR (updated for commit 51abfa0):

https://tcl-71-smart-shopping-list--pr79-ce-bugdelete-rq81u9tw.web.app

(expires Wed, 29 May 2024 15:07:57 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 1e7ade9d0f374c4ddb5d7ab6fc541062fc7a1ab4

Copy link
Collaborator

@borjaMarti borjaMarti left a comment

Choose a reason for hiding this comment

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

Ahhh I didn't know this bug was present. It has to do with how the loading state is implemented: the intent is that after confirming deletion, the loading spinner is shown. Once the list is deleted, the modal should disappear (and initially it does), but because the close state isn't modified, it reappears later when opening another modal.

No idea why that is. With your fix, we lose the loading state and we can still see and interact with the deleted list until the Firestore is updated and it triggers a re-render, but I think it's a better solution for now unless we find a way to fix the loading state not triggering a modal close.

Anyways, thank you for the fix!!

@ocsiddisco
Copy link
Collaborator Author

Ahhh I didn't know this bug was present. It has to do with how the loading state is implemented: the intent is that after confirming deletion, the loading spinner is shown. Once the list is deleted, the modal should disappear (and initially it does), but because the close state isn't modified, it reappears later when opening another modal.

No idea why that is. With your fix, we lose the loading state and we can still see and interact with the deleted list until the Firestore is updated and it triggers a re-render, but I think it's a better solution for now unless we find a way to fix the loading state not triggering a modal close.

Anyways, thank you for the fix!!

Thank for the review! I did not notice we could still click on the button list, I could not let it this way 😅 I pushed a new commit tonight, with deleteList as an async function. Let me know if you notice anything with this update. @borjaMarti

@borjaMarti
Copy link
Collaborator

borjaMarti commented May 20, 2024

Thank for the review! I did not notice we could still click on the button list, I could not let it this way 😅 I pushed a new commit tonight, with deleteList as an async function. Let me know if you notice anything with this update. @borjaMarti

Hey @ocsiddisco! Unfortunately, the problem still persisted...

After much tinkering, I think I've found a solution: passing setOpen and setSubmitted to the deleteList function. This way, when we first execute handleDelete, the loading state is rendered, and the firebase.js deleteList function is asynchronously called (meaning state updates are handled at different times). After the info is updated on the database, setOpen and setSubmitted are called, closing the dialog.

I'm going to commit it to this branch so you can check it out. If it's no good, we can revert the changes.

@ocsiddisco
Copy link
Collaborator Author

After discussing with Borja, I am pushing another commit that keeps the set state within the DeleteList component.

@ocsiddisco ocsiddisco merged commit 1a4c9c2 into main May 22, 2024
2 checks passed
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.

3 participants