| Summary: | Can't open 'Edit items' or 'Add item' links in new tab - tab is closed immediately | ||
|---|---|---|---|
| Product: | Koha | Reporter: | David Gustafsson <glasklas> |
| Component: | Staff interface | Assignee: | David Gustafsson <glasklas> |
| Status: | CLOSED FIXED | QA Contact: | Katrin Fischer <katrin.fischer> |
| Severity: | minor | ||
| Priority: | P5 - low | CC: | david, felicia.beaudry, fridolin.somers, gmcharlt, kelly, marka, martin.renvoize, mtj, nick |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: |
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24011 https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24040 |
||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | --- |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: |
This fixes a problem where the pop-up window or tab immediately closes when attempting to edit or add a bibliographic item.
|
Version(s) released in: |
19.11.00,19.05.05
|
| Circulation function: | |||
| Attachments: |
Bug 23680: Incorrect conversion of Perl boolean to js
Bug 23680: Incorrect conversion of Perl boolean to js Bug 23680: Incorrect conversion of Perl boolean to js |
||
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 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. *** |
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.