-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.15
-
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).