Summary: | Callers of confirmModal need to remove the modal as the first step in their callback function | ||
---|---|---|---|
Product: | Koha | Reporter: | Phil Ringnalda <phil> |
Component: | Templates | Assignee: | Phil Ringnalda <phil> |
Status: | RESOLVED FIXED | QA Contact: | Martin Renvoize (ashimema) <martin.renvoize> |
Severity: | major | ||
Priority: | P2 | CC: | alexbuckley, david, dcook, fridolin.somers, m.de.rooy, martin.renvoize, matt.blenkinsop, victor, wainuiwitikapark |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
GIT URL: | Change sponsored?: | --- | |
Patch complexity: | Trivial patch | Documentation contact: | |
Documentation submission: | Text to go in the release notes: |
This fixes confirm dialog boxes in the OPAC to prevent unintended actions being taken, such as accidentally deleting a list. This specifically fixes lists, and makes a technical change to prevent this happening in the future for other areas of the OPAC (such as suggestions, tags, and self-checkout).
Example of issue fixed for lists:
1. Create a list with several items.
2. From the new list, select a couple of the items.
3. Click "Delete list" and then select "No, do not delete".
4. Then select "Remove from list", and confirm by clicking "Yes, remove from list".
5. Result: Instead of removing the items selected, the whole list was incorrectly deleted!
|
|
Version(s) released in: |
25.05.00,24.11.02,23.11.14
|
Circulation function: | |
Attachments: |
Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function
Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Bug 38268: (Alternate patch) Prevent callbacks from being duplicated Bug 38268: (Follow-ups) Prevent callbacks from being duplicated Bug 38268: (Follow-up) Prevent callbacks from being duplicated Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Bug 38268: (Follow-up) Prevent callbacks from being duplicated Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Bug 38268: (Follow-up) Prevent callbacks from being duplicated |
Description
Phil Ringnalda
2024-10-24 21:56:50 UTC
Missing part of step 1: "in the OPAC", since the staff interface uses a completely different approach. Le sigh. I was starting to suspect that just hiding the modal was the problem, though why is beyond my pay-grade. Then I went looking for other places that should be affected (by having more than one caller of confirmModal), and saw that opac_user.tt should confuse cancel and suspend holds and cancel article requests. But it doesn't, because in bug 27947 three years ago AgustÃn apparently realized this was a problem and how to fix it, silently fixed it in opac_user.tt by making the first step in every callback be '$("#bootstrap-confirm-box-modal").remove()', and nobody reviewing the fix noticed it and considered other places that might need the same fix. Created attachment 173410 [details] [review] Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Templates that use confirmModal to show a pretty confirm() need to remove the modal in their callback function, or they are at risk of having the first callback called for subsequent calls that think they will get their own callback called. opac-user.tt is already fixed, opac-shelves.tt is currently affected, and opace-suggestions.tt, opac-tags.tt, and sco/sco-main.tt are at risk of being affected if anyone adds another confirmModal caller. Test plan: 1. Without the patch, open the OPAC, log in, search for something that will return several results 2. Select all - Add to list - New list 3. Lists - {your list name} 4. Click the checkboxes for the first two items 5. Instead of clicking Remove from list, accidentally click Delete list 6. In the confirmation popup, realize it was a mistake and click No, do not delete 7. Click Remove from list 8. Poof, your whole list is gone 9. Apply patch 10. Repeat steps 1-7, but instead of the whole list being deleted, see that only the selected two items were removed 11. Now intentionally click Delete list and click Yes, delete, you'll see that it is deleted rather than getting a message about nothing being removed like you would have gotten without the patch if you started by removing an item 12. On any bib detail page, click Add tag(s) and add one 13. Your account - Tags, check the checkbox for the tag, Remove selected tags, Yes, delete tag and verify that it was deleted 14. Purchase suggestions - New purchase suggestion, fill in a title and submit your suggestion, click the checkbox for your suggestion, Delete selected, Yes, delete suggestion and verify it was deleted 15. In the staff interface, find and copy the barcode for any item that can be checked out, then go to /cgi-bin/koha/sco/sco-main.pl with the OPAC hostname and port, not the staff, and log in 16. Paste the barcode in the input, click Submit, then click Finish, and in the confirmation popup click Print recept and end session, and verify that it tries to print Sponsored-by: Chetco Community Public Library Huh, I called it "normal" that if you cancel one operation and perform another, the first (destructive enough to require confirmation) operation will be done without any warning. My standards for severity are slipping. Created attachment 174995 [details] [review] Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Templates that use confirmModal to show a pretty confirm() need to remove the modal in their callback function, or they are at risk of having the first callback called for subsequent calls that think they will get their own callback called. opac-user.tt is already fixed, opac-shelves.tt is currently affected, and opace-suggestions.tt, opac-tags.tt, and sco/sco-main.tt are at risk of being affected if anyone adds another confirmModal caller. Test plan: 1. Without the patch, open the OPAC, log in, search for something that will return several results 2. Select all - Add to list - New list 3. Lists - {your list name} 4. Click the checkboxes for the first two items 5. Instead of clicking Remove from list, accidentally click Delete list 6. In the confirmation popup, realize it was a mistake and click No, do not delete 7. Click Remove from list 8. Poof, your whole list is gone 9. Apply patch 10. Repeat steps 1-7, but instead of the whole list being deleted, see that only the selected two items were removed 11. Now intentionally click Delete list and click Yes, delete, you'll see that it is deleted rather than getting a message about nothing being removed like you would have gotten without the patch if you started by removing an item 12. On any bib detail page, click Add tag(s) and add one 13. Your account - Tags, check the checkbox for the tag, Remove selected tags, Yes, delete tag and verify that it was deleted 14. Purchase suggestions - New purchase suggestion, fill in a title and submit your suggestion, click the checkbox for your suggestion, Delete selected, Yes, delete suggestion and verify it was deleted 15. In the staff interface, find and copy the barcode for any item that can be checked out, then go to /cgi-bin/koha/sco/sco-main.pl with the OPAC hostname and port, not the staff, and log in 16. Paste the barcode in the input, click Submit, then click Finish, and in the confirmation popup click Print recept and end session, and verify that it tries to print Sponsored-by: Chetco Community Public Library Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> It works! :)
> 7. Click Remove from list
> 8. Poof, your whole list is gone
OMG that's vicious, thanks for finding it out and the fix!
Started having a look at this for QA and everything works as advertised but I'm hesitant to pass QA. This fixes the existing cases but I worry about what happens the next time someone who isn't aware of this bug adds a call to confirmModal - does it not make more sense to move the removal of the existing modal up a level into the confirmModal function itself so that it is handled each time without the need to implicitly handle it in each individual callback? I'm adding an alternate patch for testing that does this - let me know your thoughts and if the behaviour works as expected Created attachment 175294 [details] [review] Bug 38268: (Alternate patch) Prevent callbacks from being duplicated (In reply to Matt Blenkinsop from comment #7) > I'm adding an alternate patch for testing that does this - let me know your > thoughts and if the behaviour works as expected The alternate makes sense to me, and thanks to both of you for cleaning up my mess. Matt could you either replace your patch with one which doesn't depend on the first one, or update your patch so that it says it's a follow-up? To me "Alternate" means the other patch isn't needed. But I like the option that gives Phil credit for providing a fix. Created attachment 175310 [details] [review] Bug 38268: (Follow-ups) Prevent callbacks from being duplicated Created attachment 175311 [details] [review] Bug 38268: (Follow-up) Prevent callbacks from being duplicated This patch moves the logic up one level into the confirmModal function to prevent future regressions Added the patch as a follow-up and set it back to NSO, Owen would you mind doing the SO? I've removed myself from QA as I've authored one of the patches, I'll pass it back into the QA pool Created attachment 175325 [details] [review] Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Templates that use confirmModal to show a pretty confirm() need to remove the modal in their callback function, or they are at risk of having the first callback called for subsequent calls that think they will get their own callback called. opac-user.tt is already fixed, opac-shelves.tt is currently affected, and opace-suggestions.tt, opac-tags.tt, and sco/sco-main.tt are at risk of being affected if anyone adds another confirmModal caller. Test plan: 1. Without the patch, open the OPAC, log in, search for something that will return several results 2. Select all - Add to list - New list 3. Lists - {your list name} 4. Click the checkboxes for the first two items 5. Instead of clicking Remove from list, accidentally click Delete list 6. In the confirmation popup, realize it was a mistake and click No, do not delete 7. Click Remove from list 8. Poof, your whole list is gone 9. Apply patch 10. Repeat steps 1-7, but instead of the whole list being deleted, see that only the selected two items were removed 11. Now intentionally click Delete list and click Yes, delete, you'll see that it is deleted rather than getting a message about nothing being removed like you would have gotten without the patch if you started by removing an item 12. On any bib detail page, click Add tag(s) and add one 13. Your account - Tags, check the checkbox for the tag, Remove selected tags, Yes, delete tag and verify that it was deleted 14. Purchase suggestions - New purchase suggestion, fill in a title and submit your suggestion, click the checkbox for your suggestion, Delete selected, Yes, delete suggestion and verify it was deleted 15. In the staff interface, find and copy the barcode for any item that can be checked out, then go to /cgi-bin/koha/sco/sco-main.pl with the OPAC hostname and port, not the staff, and log in 16. Paste the barcode in the input, click Submit, then click Finish, and in the confirmation popup click Print recept and end session, and verify that it tries to print Sponsored-by: Chetco Community Public Library Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Owen Leonard <oleonard@myacpl.org> Created attachment 175326 [details] [review] Bug 38268: (Follow-up) Prevent callbacks from being duplicated This patch moves the logic up one level into the confirmModal function to prevent future regressions Signed-off-by: Owen Leonard <oleonard@myacpl.org> Created attachment 175565 [details] [review] Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function Templates that use confirmModal to show a pretty confirm() need to remove the modal in their callback function, or they are at risk of having the first callback called for subsequent calls that think they will get their own callback called. opac-user.tt is already fixed, opac-shelves.tt is currently affected, and opace-suggestions.tt, opac-tags.tt, and sco/sco-main.tt are at risk of being affected if anyone adds another confirmModal caller. Test plan: 1. Without the patch, open the OPAC, log in, search for something that will return several results 2. Select all - Add to list - New list 3. Lists - {your list name} 4. Click the checkboxes for the first two items 5. Instead of clicking Remove from list, accidentally click Delete list 6. In the confirmation popup, realize it was a mistake and click No, do not delete 7. Click Remove from list 8. Poof, your whole list is gone 9. Apply patch 10. Repeat steps 1-7, but instead of the whole list being deleted, see that only the selected two items were removed 11. Now intentionally click Delete list and click Yes, delete, you'll see that it is deleted rather than getting a message about nothing being removed like you would have gotten without the patch if you started by removing an item 12. On any bib detail page, click Add tag(s) and add one 13. Your account - Tags, check the checkbox for the tag, Remove selected tags, Yes, delete tag and verify that it was deleted 14. Purchase suggestions - New purchase suggestion, fill in a title and submit your suggestion, click the checkbox for your suggestion, Delete selected, Yes, delete suggestion and verify it was deleted 15. In the staff interface, find and copy the barcode for any item that can be checked out, then go to /cgi-bin/koha/sco/sco-main.pl with the OPAC hostname and port, not the staff, and log in 16. Paste the barcode in the input, click Submit, then click Finish, and in the confirmation popup click Print recept and end session, and verify that it tries to print Sponsored-by: Chetco Community Public Library Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Created attachment 175566 [details] [review] Bug 38268: (Follow-up) Prevent callbacks from being duplicated This patch moves the logic up one level into the confirmModal function to prevent future regressions Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Nice cleanup and good golfing. Pushed for 25.05! Well done everyone, thank you! Nice work everyone! Pushed to 24.11.x for 24.11.01 Hi all, I have been testing these two patches for 24.05.x backport. When I have the first patch applied on 24.05.x all of the patch 1 test plan steps work exactly as noted. However, when I apply the second patch and run through the patch 1 test plan steps again I have found that step 10 fails. If I only remove two items from my list (which has more than 2 items in it) the whole list is deleted. Could someone else please apply both patches on 24.05.x and confirm if this happens for you as well? Thanks in advance, Alex I applied both patches on 24.05.x, and the test plan worked for me, only two items were deleted from the list. (In reply to Phil Ringnalda from comment #21) > I applied both patches on 24.05.x, and the test plan worked for me, only two > items were deleted from the list. Thanks Phil. That's strange we are seeing different behaviour. We have made a note to revisit this bug report next month, when we have more time to see if we can get it backported to 24.05.09 Actually, going to skip this for 24.05.x, please let us know if it is needed.
> Not backporting to 24.05.x unless requested
Sorry about all the updates, my mistake. Changed my mind. Applied to 24.05.x for 24.05.09 Pushed to 23.11.x for 23.11.14 Not backporting to 22.11 as this step of the test plan doesn't happen: 8. Poof, your whole list is gone The list does not get deleted |