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

AlternateIdentifier: value disappeares if duplicated scheme error #448

Open
jrcastro2 opened this issue Mar 9, 2022 · 2 comments
Open
Labels
bug Something isn't working ux

Comments

@jrcastro2
Copy link
Contributor

jrcastro2 commented Mar 9, 2022

Package version (if known): v0.18.0

Describe the bug

While creating a new upload if we fill in the same scheme twice in the "Alternate identifiers" it will throw an error Alternate identifiers: Only one identifier per scheme is allowed. but in the field the values will dissapear.

Note: It happens only when creating the draft for the first time.

Steps to Reproduce

  1. Go to 'New upload'
  2. Fill in the basic information
  3. Add at least 2 "Alternate identifiers" with the same scheme
  4. Click 'Save draft'
  5. See the error in the banner
  6. Scroll down and check the fields, some values disapperead

Expected behavior

Incorrect values should be highlighted with the error message.

Screenshots (if applicable)

image

Additional context

Also check other ArrayFields such as Related works as they may have the same issue.

Investigation

The issue is coming from the fact that formik's initial values are tightly coupled with the redux state. This is probably not ideal as a solution, initialValues were probably meant to keep the initial state of the form to run the diff on the fields, not to update the state from redux state(which is reflecting the backend's record payload).

As discussed internally, the form should only keep the users actions in the current state and the initialValues from the first loading point.

The record state (redux state) should be decoupled from the formik state, in order to preserve the user's operation history (only user input)

We discussed updating the initialValues only on success response, however it does not work if the error happens even before saving the first draft

@jrcastro2 jrcastro2 added the bug Something isn't working label Mar 9, 2022
@jrcastro2 jrcastro2 changed the title AlternateIdentifier: value dissapeares if duplicated scheme error AlternateIdentifier: value disappeares if duplicated scheme error Mar 9, 2022
@lnielsen lnielsen added the ux label Mar 9, 2022
@jrcastro2 jrcastro2 self-assigned this Jun 1, 2022
jrcastro2 added a commit to jrcastro2/invenio-rdm-records that referenced this issue Jun 3, 2022
jrcastro2 added a commit to jrcastro2/invenio-rdm-records that referenced this issue Jun 3, 2022
@jrcastro2 jrcastro2 changed the title AlternateIdentifier: value disappeares if duplicated scheme error [BLOCKED]AlternateIdentifier: value disappeares if duplicated scheme error Jun 3, 2022
@alejandromumo
Copy link
Member

Is this issue still blocked? Why was it blocked?

@jrcastro2
Copy link
Contributor Author

Is this issue still blocked? Why was it blocked?

Needed discussion with Zach, due to holidays we couldn't addressed it before. The main point was to remove one prop from formik (enableReinitialize) and we agreed that it can be removed if we don'f find any bugs after doing an exhaustive testing of the upload form. I will address this during this afternoon most-likely.

@jrcastro2 jrcastro2 changed the title [BLOCKED]AlternateIdentifier: value disappeares if duplicated scheme error AlternateIdentifier: value disappeares if duplicated scheme error Jun 28, 2022
@jrcastro2 jrcastro2 changed the title AlternateIdentifier: value disappeares if duplicated scheme error [BLOCKED] AlternateIdentifier: value disappeares if duplicated scheme error Jul 1, 2022
@kpsherva kpsherva assigned kpsherva and unassigned jrcastro2 Jul 5, 2022
@kpsherva kpsherva removed the blocked label Jul 6, 2022
@kpsherva kpsherva changed the title [BLOCKED] AlternateIdentifier: value disappeares if duplicated scheme error AlternateIdentifier: value disappeares if duplicated scheme error Jul 6, 2022
@kpsherva kpsherva removed their assignment Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ux
Projects
No open projects
Status: No status
Development

No branches or pull requests

5 participants