fix: prevent a backbone fieldview race condition that can delete user input#25950
Conversation
|
Thanks for the pull request, @dylan-grafmyre! I've created OSPR-5318 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
|
@dylan-grafmyre Thank you for the contribution! When you have a chance, could you please send in a signed Contributor Agreement mentioned in the earlier comment? You only need to do this once and we can then review all your future code contributions. Thanks |
86e3d61 to
8a198ec
Compare
|
Hello @natabene,
The changes I've authored are property of open-craft who I believe has an active agreement
looking at the ESLint, I think I've kicked up the dust on some grandfathered eslint exceptions, these are all from lines I did not modify (I force pushed just now to resolve a few that were on lines I changed, and re-confirmed manual testing), Whats the procedure for this situation? Do I need to fixup the rest of the file? |
|
@dylan-grafmyre Thank you for clarification. I checked our records and you have been added as thorsummoner to our list of contributors. |
|
@natabene Sorry about the confusion here - yes, Dylan is part of the team, and I can confirm that it is fine to add him as part of the OpenCraft team under the |
|
@antoviaque Thank you for confirming, no problem. @dylan-grafmyre You are all set now. |
|
I am lining this up for our review. |
|
jenkins run quality |
8a198ec to
c423efa
Compare
|
jenkins run js |
lms/static/js/views/fields.js
Outdated
There was a problem hiding this comment.
@viadanna, nit: "error" is a bit more verbose than 2.
|
👍
|
|
@natabene This is up for review 👍 |
davidjoy
left a comment
There was a problem hiding this comment.
In general looks good, thanks for doing all that linting! Small logic tweak requested, though. Then I think we'll be good to go.
lms/static/js/views/fields.js
Outdated
There was a problem hiding this comment.
Is it possible for us to just tweak the conditionals here to avoid the empty if statement? Same on the other one below.
Also, a tiny nit, on the next line "condition" is misspelled.
d3ad429 to
b42af7d
Compare
|
Your PR has finished running tests. There were no failures. |
|
@dylan-grafmyre 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
… input (openedx#25950) * prevent a backbone fieldview race condition that can delete user input eslint for effected * Fixing quality * Allow _super in fields.js * Fixing new issues * Revert some changes * Fixing errors, formatting * Fix bug * Fix eslint rule allowing _super * Refactor code Co-authored-by: Dylan Grafmyre <dylan@opencraft.com> Co-authored-by: Paulo Viadanna <paulo@opencraft.com> (cherry picked from commit 8995f1b)
… input (openedx#25950) * prevent a backbone fieldview race condition that can delete user input eslint for effected * Fixing quality * Allow _super in fields.js * Fixing new issues * Revert some changes * Fixing errors, formatting * Fix bug * Fix eslint rule allowing _super * Refactor code Co-authored-by: Dylan Grafmyre <dylan@opencraft.com> Co-authored-by: Paulo Viadanna <paulo@opencraft.com> (cherry picked from commit 8995f1b)
… input (openedx#25950) * prevent a backbone fieldview race condition that can delete user input eslint for effected * Fixing quality * Allow _super in fields.js * Fixing new issues * Revert some changes * Fixing errors, formatting * Fix bug * Fix eslint rule allowing _super * Refactor code Co-authored-by: Dylan Grafmyre <dylan@opencraft.com> Co-authored-by: Paulo Viadanna <paulo@opencraft.com> (cherry picked from commit 8995f1b)
… input (openedx#25950) * prevent a backbone fieldview race condition that can delete user input eslint for effected * Fixing quality * Allow _super in fields.js * Fixing new issues * Revert some changes * Fixing errors, formatting * Fix bug * Fix eslint rule allowing _super * Refactor code Co-authored-by: Dylan Grafmyre <dylan@opencraft.com> Co-authored-by: Paulo Viadanna <paulo@opencraft.com> (cherry picked from commit 8995f1b)
… input (openedx#25950) * prevent a backbone fieldview race condition that can delete user input eslint for effected * Fixing quality * Allow _super in fields.js * Fixing new issues * Revert some changes * Fixing errors, formatting * Fix bug * Fix eslint rule allowing _super * Refactor code Co-authored-by: Dylan Grafmyre <dylan@opencraft.com> Co-authored-by: Paulo Viadanna <paulo@opencraft.com> (cherry picked from commit 8995f1b)
JIRA tickets: BB-3171
Dependencies: None
Screenshots: Visually Identical, modified-behavior prevents user-entered text in an html input tag from being deleted, which looks like normal form text entry with least astonishment.
Merge deadline: None, Originally Nov 12 (passed due)
Testing instructions:
Manual testing:
open-craft/edx-platform, branchdylan@opencraft.com/lms-settings-race-condition) this should be sufficient to load the code changes with devstack:18000and the registration document_uri is/register), create/login to this account/account/settings)sleep 2; xdotool key F Return BackSpace S(when executing this shell command, a 2 second sleep gives time to manually alt-tab to focus on the webpage/input textbox before entering the test keystroke. This can be done by hand, by similarly pressingF<enter><backspace>Srapidly enough.If you were rapid enough to modify the text field before the network response (you can monitor the browser developer tools "network" tab to observing generated ajex request are still pending/in-flight when the keystroke is finished) we can observe: without the fix, the
Fsuffix (to visually indicate undesired behavior) overwrites theSsuffix (visually indicate desired behavior); with the fix: theFsuffix is deleted and replaced by theSsuffix and this edit stays in the input box after the previousFsuffix is acknowledged by the server/ajax response.This fix is also applied to DropDown widgets, due to requiring a physically harder keystroke, I used the utility
xdotoolto cause the dropdown submission/update to be fast enough withsleep 2; xdotool key Down Tab Shift_L+Tab Down Tab Shift_L+Tab Up Up. These fixes use the same branching logic in java script to disable overwriting user-changed input, (as in there are two copies of a small amount of nearly identical code in this PR, I'm open to converting it to a function, I don't have a good sense of preference for creating functions in backbone js contexts, I welcome your feedback).my manual testing journal:
manual testing:
- [x] observed that normal page loads (lms /accounts/settings) do not trigger any race conditions on normal form population
- [x] observed TextFieldView elements ignore the race condition by focusing (username) and entrying the keysequence "ss" rapidly
- [x] observed DropdownFieldView elements ignore the race condition by focusing the "country" dropdown and using
xdotoolto rapidly enter the key sequence:sleep 2; xdotool key Down Tab Shift_L+Tab Down Tab Shift_L+Tab Up Up
Optionally, I used this patch to log the behavior during manual testing, this temporarily helped ensure events were submitted fast enough and behaved correctly
Author notes and concerns:
Reviewers
Hello, I'm a first time openedx contributor with OpenCraft, Thank You for, and I welcome, your feedback. For example, because this is a bug-fix, it was unclear to me if I should open a Jira discussion in advance. Thanks