Bug 41128 - ratings.js creating "undefined" text for screen readers and print output
Summary: ratings.js creating "undefined" text for screen readers and print output
Status: Passed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Paul Derscheid
URL:
Keywords:
Depends on: 39706
Blocks:
  Show dependency treegraph
 
Reported: 2025-10-29 05:12 UTC by David Cook
Modified: 2025-10-31 14:39 UTC (History)
1 user (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Screenshot of "undefined" text in print output (21.86 KB, image/png)
2025-10-29 05:19 UTC, David Cook
Details
Bug 41128: Only use data rating if it's available (1.46 KB, patch)
2025-10-29 05:26 UTC, David Cook
Details | Diff | Splinter Review
Bug 41128: Only use data rating if it's available (1.52 KB, patch)
2025-10-29 12:18 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 41128: Only use data rating if it's available (1.62 KB, patch)
2025-10-31 14:35 UTC, Paul Derscheid
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2025-10-29 05:12:11 UTC
If you try to print the user summary table, you'll likely see a bunch of "undefined" text in the table.

It looks like ./koha-tmpl/opac-tmpl/bootstrap/js/ratings.js iterates through some of the HTML and tries to create spans with text from the data-rating-value attribute, but that attribute doesn't exist, so it uses the text "undefined" instead:

<div class="br-widget br-readonly">
    <a href="#"><span class="sr-only">undefined</span></a>
    <a href="#"><span class="sr-only">undefined</span></a>
    <a href="#"><span class="sr-only">undefined</span></a>
    <a href="#"><span class="sr-only">undefined</span></a>
    <a href="#"><span class="sr-only">undefined</span></a>
</div>
Comment 1 David Cook 2025-10-29 05:19:01 UTC
Created attachment 188544 [details]
Screenshot of "undefined" text in print output
Comment 2 David Cook 2025-10-29 05:26:45 UTC
Created attachment 188545 [details] [review]
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
Comment 3 Owen Leonard 2025-10-29 12:18:49 UTC
Created attachment 188547 [details] [review]
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 <oleonard@myacpl.org>
Comment 4 Paul Derscheid 2025-10-31 14:35:31 UTC
Created attachment 188825 [details] [review]
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 <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>