Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85526

Bug in "generateAriaLabels()" in paged_content_paging_bar.js

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.1.15
    • Other
    • MOODLE_401_STABLE

      There is a bug in the paged_content_paging_bar implementation which prevents the paging bar's aria labels to be correct.

      Note: this can only be viewed from paged content that has been created with factory::createWithTotalAndLimit().

      The wrongful implementation is in paged_content_paging_bar.js, line 411:

              var stringRequests = pageItems.toArray().map(function(index, page)

      The order of the 2 parameters is wrong (and has already been introduced 7 years ago with the first improvement to the paged content factory, see https://github.com/moodle/moodle/commit/2c13ae01d9796c5a1ddeec6b106c814477bf2dd3)

      Since pageItems (and later pageItems.toArray()) is a pure JS Array, the map function expects the first parameter to be the "current" object, not the index (this is not jquery, which does have index as the first callback argument and the current object as the second callback argument in it's "each" function).
      Hence, $(index) = $(<number>). This will always create an empty JQuery object since no DOM element is used to create the JQuery object.
      This means "getPageNumber()" will always return 1.

      Consequentially, all paging bar items have an aria label refering to "page 1".

      To reproduce:

      • Enter 60+ entries in table "lti_types" (unfortunately; there's a 60 items per page hard limit here for the management interface).
      • Navigate to https://<yourhost>/mod/lti/toolconfigure.php
      • Verify that you have 2 pages in your interface:
      • Open your browser's inspector window, confirm all items have been marked with "page 1":
      • Navigate to your "sources" tab in the browser's inspector, find /lib/amd/src/paged_content_paging_bar.js, line 412 (page = $(page)) and mark it as a breakpoint.
      • Reload the page (keep browser inspector open)
      • Verify the incorrectness of both "page" and "index":
      • I've marked the first Moodle version I could still select as affected version, although it really affects all branches from 3.6.0 onwards, inclusing the current state (at the time of writing).

       

        1. screen1.png
          screen1.png
          25 kB
        2. screen2.png
          screen2.png
          52 kB
        3. screen3.png
          screen3.png
          63 kB
        4. Screenshot 2025-06-04 at 2.28.07 pm.png
          Screenshot 2025-06-04 at 2.28.07 pm.png
          145 kB

            Unassigned Unassigned
            rogiervandongen Rogier van Dongen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 31 minutes
                31m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.