Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Locally store values entered in draft for line item #652

Open
coderbyheart opened this issue Mar 2, 2022 · 2 comments
Open

Locally store values entered in draft for line item #652

coderbyheart opened this issue Mar 2, 2022 · 2 comments
Labels
front end good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@coderbyheart
Copy link
Member

coderbyheart commented Mar 2, 2022

The LineItemForm needs a way to preserve partially entered data, so if the user navigates to another line item, their input is not lost.

I tried adding storing of data to the code myself, but failed and creating endless loops with react-hook-form. This seems to be a common issue, and I couldn't figure out, how to do it.

See this private Notion card:

Clicking ‘Add Item’ before saving Line Item loses data in item.

@coderbyheart coderbyheart added good first issue Good for newcomers help wanted Extra attention is needed front end labels Mar 2, 2022
@coderbyheart coderbyheart added this to the v1 milestone Mar 2, 2022
@RabeaGleissner
Copy link
Contributor

I had some thoughts about this while looking through the code today.

I can see why it's annoying for a user to lose the data that they carefully typed into the form when they click on a different line item. If we were to save their state (for example in local storage, like @coderbyheart is suggesting), that would work well for new, unsubmitted items. But what about submitted forms that are being edited? We'd need to indicate in the UI which changes are actually submitted and which ones are just "remembered" by the browser. That might become a bit confusing to the user and also difficult to implement.

If the problem we're trying to solve is that changes are lost when clicking on a different line item, then I can think of a few other approaches:

  • ask the user if they want to save or cancel when they click on a different line item and the current form is dirty
  • submit the current form on blur (editing or deleting the form is easy, so no harm in saving the data, I think)
  • disable clicking on other items while the form has unsubmitted changes

What do you think?

Screenshot for ease of understanding what these line items are we're talking about!

image

@coderbyheart
Copy link
Member Author

I think warn on dirty form is the best option.
We can't save partial forms server side, because they are invalid.
Blocking other UI elements feels very intrusive and is not a common pattern (we would need to move the form to a modal or other form of UI element that ONLY has the form).

@coderbyheart coderbyheart added this to To Do (prioritized) in Shipment Tracker May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
front end good first issue Good for newcomers help wanted Extra attention is needed
Projects
Shipment Tracker
To Do (prioritized)
Development

No branches or pull requests

2 participants