-
Notifications
You must be signed in to change notification settings - Fork 652
AO3-7214 AO3-7215 Bookmark Javascript Improvement #5499
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
base: master
Are you sure you want to change the base?
Conversation
Changed id to class so that every button that can do one feature behaves the same and changed the organisation of the jquery
Since the new tests have been moved to their new feature file to test javascript feature these are not needed
|
Appologies if having multiple ticket in one PR is bad etiquette. I decided to put both in the same PR, as they were extremely closely related, and would likely be waiting on each other if done separately. |
|
yeah, putting two tickets in one pr is fine when it's exact the same fix for both though the pr name should begin like this: "AO3-7214 AO3-7215" |
Changed the PR name accordingly |
sarken
left a comment
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 for working on this! In addition to the question I left on the JavaScript file, I think you also need to changeid to class for the buttons in the bookmarkable_blurb, which is used for pages where we show multiple bookmarks under a single item, e.g., a tag's bookmark listing.
| $j('#bookmark_form_close_for_<%= bookmark_form_id %>').click(function(){ | ||
| $j('#bookmark_form_placement_for_<%= bookmark_form_id %>').hide(); | ||
| $j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').show(); | ||
| $j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').attr('href', '#'); |
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.
I was a little confused by this line. It didn't seem necessary at first, but when I removed it, I noticed that it seems to fix an issue introduced by the other changes in this file.
Here's what I noticed:
Currently, if I go to a bookmarks index, press "Save" on something I don't have bookmarked, enter some text in the form, and then use the "x" to close the form without saving, the form opens with my text entered the next time I press "Save."
It seems like that behavior breaks when this line is removed: the second time I press "Save," the form gets reloaded and my text is lost.
Is that indeed what this line is fixing? If so, do you know why that bug happens, and if there is any other way we could avoid it? Removing the original href means it's no longer possible to right-click "Save" and open the form in a new window, which is somewhat unfortunate. We can live with it if we have to, but it would be a good idea to have a code comment explaining why this line is needed.
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.
Which line in particular are you referring to?
As for the href, the reason why it's removed is the route of the bookmark is rendering the form as part of the controller (see line 176 of the bookmark controller). However, hiding with the x goes through the dynamic.js.erb file (above). If we don't do that, 7215 is reintroduced (since it will go through the controller to find the route of the link instead of the javascript watcher).
An alternate solution would be to delete the form instead of hiding it. That way, rendering would always work since the form would not be there already. Is the behavior you mentioned not already occurring if you close and open a bookmark on the works page having written stuff already?
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.
Which line in particular are you referring to?
The line removing the href, sorry! GitHub told me the comment was only on line 12 before I submitted the review, but it appears to have lied.
If we don't do that, 7215 is reintroduced (since it will go through the controller to find the route of the link instead of the javascript watcher).
For me, 7215 remained fixed without this line. The only difference in behavior was the information I had entered in the form was lost upon re-opening it (which would be consistent with opening a new form instead of un-hiding the original). But based on your explanation, I suspect if I had re-opened the form twice instead of just once, I would've run into 7215.
An alternate solution would be to delete the form instead of hiding it.
That would mean losing any information you had entered in the form before closing it, so we don't want to do that. While we could store that information somewhere and retrieve it when you re-open the form, it's probably not worth the extra code. If we get complaints about the removal of the right-click functionality, we can reconsider.
Is the behavior you mentioned not already occurring if you close and open a bookmark on the works page having written stuff already?
The form currently (i.e., on production) keeps what I've written.
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.
I believe if you go on the works index, open a bookmark form and close it again you can't open it with a right click anymore.
I've tried changing some stuff to make the right click work, but I'm unsure how to approach it.
Issue
https://otwarchive.atlassian.net/browse/AO3-7214
https://otwarchive.atlassian.net/browse/AO3-7215
Purpose
This adresses both tickets 7214 and 7215 by making all buttons that could edit a bookmark disappear when the form is open, by allowing a closed form to be reopened (7215) and by fixing the opening and closing of multiple forms at the same time.
7214 was fixed by removing the variables and jquerying the appropriate component each time the form is closed or reopened.
7215 was fixed by changing the href of the opening buttons as part of the closing event, as well as changing the id to a class so every element is affected at the same time.
Credit
Danaël / Rever ( they / he )
Jira account goes by Danaël Villeneuve