-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Discussion] Refactor Save & Recover in Comment/Legacy Editor Form #9131
Comments
My PR #9132 refactors the save and recover methods like so: plots2/app/assets/javascripts/editor.js Lines 118 to 125 in 0811c5e
The unique comment form ID string is embedded in the localStorage key as
|
* merge branches #9104 #9107 #9108 #9110 #9118 * change #dropzone-large ID to #comment-form-body * add comprehensive preview button test * add text-input class, data-form-id attribute to textarea #9004 #9131 * add data-form-id to save & recover buttons #9004 #9131 * E.setState when clicking save, recover, & .text-input #9004 #9131 * refactor save & recover #9004 #9131 * add icon to recover button #9004 #9131 * restore edit button tooltip #9004 #9131 * save with window.location.pathname, not href #9004 #9131 * new system test for save & recover #9004 #9131 * update test selector #9004 #9131
Discussion Point 1: When/How to Save User Input?The old way of saving user input happened like this. As soon as a comment form was selected, this eventListener was attached: plots2/app/assets/javascripts/editor.js Line 35 in 6ded8c4
plots2/app/assets/javascripts/editor.js Lines 112 to 114 in 6ded8c4
This means that every time a user made any kind of input (typed, deleted, pasted text, etc.) in a given text-input, their input would be automatically saved into localStorage. Basically this means two things:
And where does that leave the recover button? In the past, the recover button was very buggy. For a few reasons:
Now that cross-wiring seems to largely be a thing of the past 🤞, the
Otherwise the
|
Discussion Point 2: What Do We Signal to User?Given all of the above... I think it's worth talking about as a community how we want If the
|
Side note: I noticed that Ideal: Visiting
|
Hmm. one thing I thought of wrt the localstorage issue is that it can sometimes happen that we try to execute JS before a page is finished loading, and in test environments perhaps this is harder to notice? But it's just a guess.
I like the solution you did with unique IDs. But noting that possibly this could prevent recovery on a page which no longer exists, or a comment which no longer exists? But still, recovery is an "as good as we can do" kind of thing so perhaps it's OK. I guess I agree about Save being useless -- i think we started saving automatically after we added the basic function. How about this -- the save button could become a non-clickable Thanks for so carefully thinking through this!!! |
* merge branches publiclab#9104 publiclab#9107 publiclab#9108 publiclab#9110 publiclab#9118 * change #dropzone-large ID to #comment-form-body * add comprehensive preview button test * add text-input class, data-form-id attribute to textarea publiclab#9004 publiclab#9131 * add data-form-id to save & recover buttons publiclab#9004 publiclab#9131 * E.setState when clicking save, recover, & .text-input publiclab#9004 publiclab#9131 * refactor save & recover publiclab#9004 publiclab#9131 * add icon to recover button publiclab#9004 publiclab#9131 * restore edit button tooltip publiclab#9004 publiclab#9131 * save with window.location.pathname, not href publiclab#9004 publiclab#9131 * new system test for save & recover publiclab#9004 publiclab#9131 * update test selector publiclab#9004 publiclab#9131
* merge branches publiclab#9104 publiclab#9107 publiclab#9108 publiclab#9110 publiclab#9118 * change #dropzone-large ID to #comment-form-body * add comprehensive preview button test * add text-input class, data-form-id attribute to textarea publiclab#9004 publiclab#9131 * add data-form-id to save & recover buttons publiclab#9004 publiclab#9131 * E.setState when clicking save, recover, & .text-input publiclab#9004 publiclab#9131 * refactor save & recover publiclab#9004 publiclab#9131 * add icon to recover button publiclab#9004 publiclab#9131 * restore edit button tooltip publiclab#9004 publiclab#9131 * save with window.location.pathname, not href publiclab#9004 publiclab#9131 * new system test for save & recover publiclab#9004 publiclab#9131 * update test selector publiclab#9004 publiclab#9131
Made a more contributor-friendly breakdown of this issue in #9362, so closing this one. |
* merge branches publiclab#9104 publiclab#9107 publiclab#9108 publiclab#9110 publiclab#9118 * change #dropzone-large ID to #comment-form-body * add comprehensive preview button test * add text-input class, data-form-id attribute to textarea publiclab#9004 publiclab#9131 * add data-form-id to save & recover buttons publiclab#9004 publiclab#9131 * E.setState when clicking save, recover, & .text-input publiclab#9004 publiclab#9131 * refactor save & recover publiclab#9004 publiclab#9131 * add icon to recover button publiclab#9004 publiclab#9131 * restore edit button tooltip publiclab#9004 publiclab#9131 * save with window.location.pathname, not href publiclab#9004 publiclab#9131 * new system test for save & recover publiclab#9004 publiclab#9131 * update test selector publiclab#9004 publiclab#9131
* merge branches publiclab#9104 publiclab#9107 publiclab#9108 publiclab#9110 publiclab#9118 * change #dropzone-large ID to #comment-form-body * add comprehensive preview button test * add text-input class, data-form-id attribute to textarea publiclab#9004 publiclab#9131 * add data-form-id to save & recover buttons publiclab#9004 publiclab#9131 * E.setState when clicking save, recover, & .text-input publiclab#9004 publiclab#9131 * refactor save & recover publiclab#9004 publiclab#9131 * add icon to recover button publiclab#9004 publiclab#9131 * restore edit button tooltip publiclab#9004 publiclab#9131 * save with window.location.pathname, not href publiclab#9004 publiclab#9131 * new system test for save & recover publiclab#9004 publiclab#9131 * update test selector publiclab#9004 publiclab#9131
Just submitted a PR that refactors
editor.js
's save & recover methods.Here's the old version of
save
andrecover
:plots2/app/assets/javascripts/editor.js
Lines 112 to 117 in 2188e0a
Basically,
editor.js
sets an eventHandler here below. Any time the user types into a textarea,$E.save
runs:plots2/app/assets/javascripts/editor.js
Line 35 in 2188e0a
The main concern here is... What happens on a page with multiple comment forms?
The
plots:lastpost
key inlocalStorage.setItem('plots:lastpost', this.textAreaValue);
is static. Because of that, something like this can happen:#text-input-main
, triggering save eventListener.plots:lastpost
in localStorage.#text-input-reply-1
.#text-input-reply-1
.editor.js
looks upplots:lastpost
in localStorage, then inputs the text value from#text-input-main
into reply form#text-input-reply-1
, which is weird!(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)
The text was updated successfully, but these errors were encountered: