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

Data is getting erased while navigating to other screens #384

Open
Mohith93 opened this issue Sep 27, 2024 · 6 comments
Open

Data is getting erased while navigating to other screens #384

Mohith93 opened this issue Sep 27, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Mohith93
Copy link

Describe the bug
In any point during navigating on screen , when User navigates back, Data is getting erased

To Reproduce
Steps to reproduce the behavior:

  1. Login into application
  2. On Source/ Destination / Models / Sync hit back
  3. observe

Actual Behaviour: Filled data is getting erased

Expected behavior
Data should not get cleared when user navigating back to previous screen.

@Mohith93 Mohith93 added bug Something isn't working hacktoberfest labels Sep 27, 2024
Copy link

linear bot commented Sep 27, 2024

@Mohith93 Mohith93 changed the title In any point of screen , User navigates back, Data is getting erased Data is getting erased while navigating to other screens Sep 27, 2024
@xyfer17
Copy link
Contributor

xyfer17 commented Oct 7, 2024

@Mohith93 @macintushar please assign this issue to me, i would like to resolve this issue.

@macintushar
Copy link
Member

@xyfer17 assigned it to you. Would like to know how you are planning on implementing this after you go through the current code.

@xyfer17
Copy link
Contributor

xyfer17 commented Oct 14, 2024

@macintushar sorry for the delayed response. for the above issue I'm planning to save the form data in localStorage, so it won’t be erased when navigating to other screens.

Here’s the approach I’m thinking of:

  1. state initialization from localStorage: on component mount, I'll check localStorage for any saved form data and pre-fill the form if data is available.
  2. capture form Data on change: as the form changes, I’ll store the data in localStorage to ensure it’s retained across navigation.
  3. clear data on submission: once the form is submitted successfully, I’ll clear the saved data from localStorage.
  4. component unmount handling: I’ll add a beforeunload listener to clear the data if needed when the browser is closed or refreshed.

Let me know if you have any suggestions on above approach or a better approach! 👍

@macintushar
Copy link
Member

@xyfer17 need you to think about how you'll manage data if I fill out the form as:

  1. open in account A, fill the form, close it and login with account B

@xyfer17
Copy link
Contributor

xyfer17 commented Oct 15, 2024

@xyfer17 need you to think about how you'll manage data if I fill out the form as:

  1. open in account A, fill the form, close it and login with account B

@macintushar for this scenario ,if users logout the localStorage would clear ideally and the formData is also removed along with it.
so that account B doesn't have the account A data prefilled in the form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants