contentTranslationDependentOptions behavior doesn't check if found element array is empty

Created on 20 December 2023, 12 months ago
Updated 9 March 2024, 9 months ago

Problem/Motivation

The Content Translation module includes a Drupal behavior in core/modules/content_translation
/content_translation.admin.js.

This behavior at some point processes the received $context to locate input elements:

$fields = $context.find(`input[name^="${field}"]`);

However, it doesn't check if $fields array is empty, causing JS errors when it is indeed empty:

Uncaught TypeError: Cannot read properties of undefined (reading 'matches')

Steps to reproduce

  1. Install a fresh Drupal site
  2. Enable content translation (drush en content_translation)
  3. Go to "Content language and translation" at /admin/config/regional/content-language

The JS error should be displayed in the browser console.

Proposed resolution

Check if $fields is empty.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Not needed.

🐛 Bug report
Status

Closed: duplicate

Version

11.0 🔥

Component
Content translation 

Last updated about 1 hour ago

No maintainer
Created by

🇪🇸Spain tunic Madrid

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024