Steps to reproduce: 1. Add several items to a list 2. Click the checkbox for an item, then accidentally click 'Delete list' rather than 'Delete selected items' 3. Click the 'No, do not delete' button in the confirmation asking if you want to delete the list 4. Click 'Delete selected items' like you meant to 5. Click 'Yes, remove from list' in the confirmation which lists the two items you selected Expected result: the two selected items are removed from the list, leaving the rest and the list intact Actual result: the entire list is deleted
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.