-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add support for unsaved changes to EditableList. STCOM-26. #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me. Nice work!
One thing I noticed: if I click the “Edit” button for multiple items, change multiple items, then click one “Save” button, the edits for the other items disappear. I suspect this is not a common use case as only a BOFH would bother deliberately trying break it this way, but it is something to know about, if not to bother fixing. I suspect this is related to using the FieldArray rather than a series of independent forms. I found FieldArray to be double-edged in that regard when I first started looking at this before it landed on your plate.
Everything in the code looks fine to me — even ESLint runs cleanly!
Thank you for the review @zburke and for catching these extra issues! It appears that there is another flag in |
Michal,
I like the cleanliness of things, but I believe I’ve encountered a bug.
If you edit/save an item with a change that will change the sorting order of the list, the item keeps its place, but the fields seem to update/show values from the updated order. To reproduce:
Patron groups has groups in this order:
faculty – Faculty Member
graduate – Graduate Student
staff - Staff Member
undergrad – Undergraduate Student
Click edit on the second item - graduate – add a 2 to the beginning of the name “2graduate” (that would send it to the beginning) and save. Now the fields read
faculty – Faculty Member
2graduate – Faculty Member
staff - Staff Member
undergrad – Undergraduate Student
It’s like it’s used the description value for the 2nd item from the proper sort order – The appropriate values are still there somewhere ( I can edit > cancel on the first and sedond items and they appear as they should be)
Just not being properly rendered/updated in the right places.
|
@JohnC-80 Thank you for your review and for catching this issue. Unfortunately it looks like this started happening after I added |
Fixes UIIT-36, UIIT-48, UIU-148 and UIU-79
@JohnC-80 and @zburke this PR introduces a new version of
<EditableList>
with a support for navigation check in cases when the unsaved changes are detected. @JohnC-80 the work is based onFieldArray
(thank you for recommending it). It allowed for easier state management for each item inside the form.I tried to keep the current API for
<EditableList>
aligned with the previous version so it stays compatible with the apps. It seems like things are working well but it would be great if you could review it. Thank you!