Sort broken in Drupal 11 / jQuery 4

Created on 18 August 2025, about 1 month ago

Problem/Motivation

The Tablesort jQuery plugin is broken in Drupal 11 / jQuery 4. It produces an error in the console: TypeError: $.trim is not a function. (In '$.trim( val )', '$.trim' is undefined). This trim function has been removed in jQuery 4. The error makes it no longer possible to sort items in a sitemap by clicking a column header.

Steps to reproduce

On Drupal 11, install this module and create a sitemap. Ensure "Add styling and sorting to sitemaps" is enabled for the sitemap, and visit it in the browser. You'll see an error in the console and clicking the column headers does nothing.

Proposed resolution

It doesn't appear Tablesort is actively maintained, so either choose a different method for sorting the table or modify Tablesort to remove this missing function.

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States timurtripp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @timurtripp
  • πŸ‡ΊπŸ‡ΈUnited States timurtripp
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    Sorting does not seem to work though I don't see any error message in the console.

    Personally I am not sure why we I added table sorting - it seems like a barely useful feature to me. Since sorting doesn't work anyway, I guess it won't hurt to remove it and see if it breaks some odd use case.

    Do you have any idea (or a way to check) if sorting works on Drupal 10.2?

  • πŸ‡¨πŸ‡¦Canada danrod Ottawa

    Hi there,

    In no fix is provided for this issue here, I have developed this module that implements these deprecated jQuery modules, you can use this if you want: https://www.drupal.org/project/jquery_deprecated_functions β†’

  • πŸ‡ΊπŸ‡ΈUnited States timurtripp

    @gbyte Use case was for the SEO team sorting to get the latest content on the site. This can obviously be done from within Drupal but only if the user is signed in and has the necessary permissions to do so. Sitemaps are public so this wasn't a requirement before.

  • πŸ‡ΊπŸ‡ΈUnited States timurtripp

    @gbyte Not sure about 10.2 but it works in 10.5. Issue is specific to Drupal 11 & jQuery 4 as mentioned.

  • πŸ‡©πŸ‡ͺGermany hosterholz

    Table sorting does work in Drupal 10.2 in Chrome, but not in Firefox. Firefox does not seem to fire "DOMContentLoaded" in XSL. I replaced document.addEventListener('DOMContentLoaded', () => {}) with $(document).ready(() => {}) in simple_sitemap.xsl.js. This makes table sorting work in Firefox (and Drupal 10.2).

    In Drupal 11.2 the modified simple_sitemap.xsl.js also throws the JavaScript-Error in Firefox.

    The used tablesorter library uses deprecated functions in many places and is not compatible with jQuery 4 which is used in Drupal 11.2. See tablesorter issue #1852.

    Another possibility to fix this would be shipping jQuery 3 with simple_sitemap and including it in the sitemap instead of core's jQuery.

  • πŸ‡ΊπŸ‡ΈUnited States damienmckenna NH, USA

    Tagging to make it easier to find this issue.

Production build 0.71.5 2024