multiwoven icon indicating copy to clipboard operation
multiwoven copied to clipboard

Data is getting erased while navigating to other screens

Open Mohith93 opened this issue 1 year ago • 6 comments

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 avatar Sep 27 '24 13:09 Mohith93

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

xyfer17 avatar Oct 07 '24 15:10 xyfer17

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

macintushar avatar Oct 09 '24 10:10 macintushar

@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! 👍

xyfer17 avatar Oct 14 '24 15:10 xyfer17

@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 avatar Oct 15 '24 13:10 macintushar

@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.

xyfer17 avatar Oct 15 '24 14:10 xyfer17