From dcdd62eab90d440a319398d3cf8aa0657d7393af Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 18 Sep 2024 17:49:21 +0000 Subject: [PATCH] Bug 37946: Double menu when clicking the caret in Z39.50 search Content-Type: text/plain; charset=utf-8 This patch makes some adjustments to the JS for the Z39.50 search results page to correct the behavior of dropdown menus. If the split button's menu trigger is clicked a cloned version of the menu shouldn't appear along with the default one. To test, apply the patch and clear your browser cache if necessary. - Go to Cataloging -> New from Z39.50. - Perform a search which will return multiple results. - Click any table cell in the results except the last one. - You should get a popup menu with "MARC preview," "Card preview," and "Import." - Each menu item should work correctly. - Test the button in the last column to confirm that both the "primary" button works correctly and that the popup menu works correctly. - Test the process of adding a new authority from Z39.50 to confirm that the authority search results table works the same as the bibliographic one. Signed-off-by: David Nind Signed-off-by: Phil Ringnalda Signed-off-by: Marcel de Rooy --- .../intranet-tmpl/prog/js/z3950_search.js | 51 ++++++++----------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js b/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js index 8a7c0ca596..96c9b1f8b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js +++ b/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js @@ -78,37 +78,30 @@ $( document ).ready( function() { var link = $( "a[title='" + tgt.text() + "']", row ); if( link.length == 1) link.click(); row.find('ul.dropdown-menu').hide(); + return; } else { - event.stopPropagation(); - /* Remove the "open" class from all dropup menus in case one is open */ - $(".dropup").removeClass("open"); - /* Create a clone of the Bootstrap dropup menu in the "Actions" column */ - var menu_clone = $(".dropdown-menu", row) - .clone() - .addClass("menu-clone") - .css({ - "display" : "block", - "position" : "absolute", - "top" : "auto", - "bottom" : "100%", - "right" : "auto", - "left" : "0", - }); - /* Append the menu clone to the table cell which was clicked. - The menu must first be wrapped in a block-level div to clear - the table cell's text contents and then a relative-positioned - div to allow the menu to be positioned correctly */ - if( tgt.prop('nodeName') != 'TD' ) { - // handling click on caret to improve menu position - tgt = tgt.closest('td'); - } - tgt.append( - $('
', {'class': 'btn-wrapper'}).append( - $('
', {'class': 'btn-group'}).append( - menu_clone + if( tgt.prop('nodeName') == 'TD' && !tgt.hasClass("actions") ){ + /* Create a clone of the Bootstrap dropup menu in the "Actions" column */ + var menu_clone = $(".dropdown-menu", row) + .clone() + .addClass("show") + .css({ + "display" : "block", + "position" : "absolute", + "top" : "auto", + "bottom" : "100%", + "right" : "auto", + "left" : "0", + }); + + tgt.append( + $('
', {'class': 'btn-wrapper'}).append( + $('
', {'class': 'btn-group'}).append( + menu_clone + ) ) - ) - ); + ); + } } }); -- 2.39.5