From a3e341c24093634647f24c8b6b8fb764a8b0d86c Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 29 Oct 2025 05:24:12 +0000 Subject: [PATCH] Bug 41128: Only use data rating if it's available This patch prevents span elements being filled with "undefined" which are then shown to screen readers and print output. Test plan: 0. Apply the patch 1. Enable the following system preference: OpacStarRatings (results, details, and patron). 2. Check out an item to a user you can log in as (e.g. koha user) 3. Go to /cgi-bin/koha/opac-user.pl in the OPAC 4. Click "Print" on the toolbar above the summary table 5. Note that 5 occurrences of "undefined" do not appear next to the title in the print output Signed-off-by: Owen Leonard --- koha-tmpl/opac-tmpl/bootstrap/js/ratings.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js b/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js index 40ff854071e..a60fe2a81ab 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js @@ -70,7 +70,9 @@ $(document).ready(function () { $(this).replaceWith(span); } else { var data_rating = $(this).attr("data-rating-value"); - $(this).append('' + data_rating + ""); + if (data_rating){ + $(this).append('' + data_rating + ""); + } } }); }); -- 2.39.5