-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Show error messages without clearing inputs in edition edit page #8777
Show error messages without clearing inputs in edition edit page #8777
Conversation
8802d00
to
924fa07
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #8777 +/- ##
==========================================
+ Coverage 16.62% 16.65% +0.03%
==========================================
Files 88 88
Lines 4698 4706 +8
Branches 838 838
==========================================
+ Hits 781 784 +3
- Misses 3399 3404 +5
Partials 518 518 ☔ View full report in Codecov by Sentry. |
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.
Thanks @rebecca-shoptaw, and sorry for the delay! Great job on this. I think that we mislabeled the corresponding issue as a Good first issue
, as the validation code isn't the easiest to work with...
Because this hasn't been reviewed in a timely manner, I'm going to commit my suggested changes and merge this. If any of my changes seem wrong to you, let me know and we can fix it.
Closes #8423
Fix. Makes the inputs for adding contributors, classifications, identifiers, excerpts and links (on the
Edit
page and theWork Details
page) only clear once the input is accepted -- to make it easier for users to fix typos/etc. if rejected instead of having to re-type their entry.Technical
This ended up being a little more involved than expected. Since the values were automatically clearing (to be saved separately in a
data
variable) before the error checks ran, I initially implemented a workaround solution that used thedata
values to manually re-set the input fields to their lost values after the error checks.After this, I discovered that the root of the problem was actually in the
jquery.repeat.js
file, where all text inputs were being cleared as a side effect of storing the values indata
.So I removed that line from the function, and added value clearing to each relevant function to run only after the error checks pass. I.e.
$('#select-role, #role-name').val('');
This all worked great, and made the UI behave as desired -- and had the added benefit of clearing the role/identifier type as well when the entry is accepted.
Edit: Got the tests passing by adjusting the process for identifier validation specifically --
formdata
now does clear the inputs, but just for identifier entries. The inputs are re-entered via$('#id-value).val(data.value)
in a couple places so that the input remains in the case of errors likeno identifier type selected
.Other Technical Notes
This also involved some cleanup along the way, specifically fixing some typos in the calls to the
error()
function to make sure the error message displayed and the correct input was focused on, and two quick HTML rewrites to improve the URL validation inweb.html
and make the excerpt error show/hide properly inexcerpts.html
.Testing
Screenshot
Stakeholders
@jimchamp