In cataloging_additem.inc the javascript variable "popup" is generated as: var popup = '[% popup | html %]'; So popup will be either '0' or '1'. '0' is a truthy value in javascript, so popup will always be evaluated as true making this condition: if( popup && op != 'saveitem' ){ window.close(); } in cataloging_additem.js (incorrectly) true for every operation except saveitem. A windows can only be closed by javascript in certain conditions (don't know if all browsers behave exactly the same), but for window.close() to actually close the window it needs to be opened in new window/tab. So to reproduce this bug go to a bibliographic record, expand the "New" menu, and open "New item" in new tab. It should immediately close, which this patch should fix.
Created attachment 93166 [details] [review] Bug 23680: Incorrect conversion of Perl boolean to js A Perl boolean value is on the server side converted to a JS string (resulting in the values '0' or '1). Since the string '0' is a truthy value in JS this incorrectly triggers window.close() on the client in many instances, for example when adding a new item. To test: 1. Go to a bibliographic record in the staff client. 2. Expand the "New" menu and open "New item" in new tab. 3. The new tab will immediately close. 4. Apply the patch. 5. Perform steps 1-2 again. 6. The tab should now remain open. Sponsored-by: Gothenburg University Library
I think this bug was introduced in Bug 21091.
Created attachment 93176 [details] [review] Bug 23680: Incorrect conversion of Perl boolean to js A Perl boolean value is on the server side converted to a JS string (resulting in the values '0' or '1). Since the string '0' is a truthy value in JS this incorrectly triggers window.close() on the client in many instances, for example when adding a new item. To test: 1. Go to a bibliographic record in the staff client. 2. Expand the "New" menu and open "New item" in new tab. 3. The new tab will immediately close. 4. Apply the patch. 5. Perform steps 1-2 again. 6. The tab should now remain open. Sponsored-by: Gothenburg University Library Signed-off-by: David Nind <david@davidnind.com>
I tested this with the latest Firefox and Google Chrome browsers on Ubuntu 18.04. With pop ups allowed for both browsers: - On Firefox the behaviour identified didn't occur, that is: the window opened fine in a new tab (both before and after the patch) - On Google Chrome the behaviour identified occurred and the patch fixed it.
Please don't forget to assign the bug to you when you start working on it!
(In reply to David Nind from comment #4) > I tested this with the latest Firefox and Google Chrome browsers on Ubuntu > 18.04. > > With pop ups allowed for both browsers: > > - On Firefox the behaviour identified didn't occur, that is: the window > opened fine in a new tab (both before and after the patch) > > - On Google Chrome the behaviour identified occurred and the patch fixed it. Thx for the hints about Browsers, David!
Created attachment 93563 [details] [review] Bug 23680: Incorrect conversion of Perl boolean to js A Perl boolean value is on the server side converted to a JS string (resulting in the values '0' or '1). Since the string '0' is a truthy value in JS this incorrectly triggers window.close() on the client in many instances, for example when adding a new item. To test: 1. Go to a bibliographic record in the staff client. 2. Expand the "New" menu and open "New item" in new tab. 3. The new tab will immediately close. 4. Apply the patch. 5. Perform steps 1-2 again. 6. The tab should now remain open. Sponsored-by: Gothenburg University Library Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Nice work! Pushed to master for 19.11.00
*** Bug 23782 has been marked as a duplicate of this bug. ***
*** Bug 23490 has been marked as a duplicate of this bug. ***
2 duplicates filed already - changing bug title to make it more readable.
Pushed to 19.05.x for 19.05.05
*** Bug 24040 has been marked as a duplicate of this bug. ***