diff --git a/core/modules/content_translation/content_translation.admin.js b/core/modules/content_translation/content_translation.admin.js index 463525b1bcfab54305e5d8bc2e966d89ff790b17..17b87001fc4658acda3eb623aa2a9437ee88f0c5 100644 --- a/core/modules/content_translation/content_translation.admin.js +++ b/core/modules/content_translation/content_translation.admin.js @@ -61,7 +61,10 @@ $element = $fields.filter(filterFieldsList); } - if ($element[0].matches(`input[value="${column}"]:checked`)) { + if ( + $element.length && + $element[0].matches(`input[value="${column}"]:checked`) + ) { $fields.prop('checked', true).not($element).prop('disabled', true); } else { $fields.prop('disabled', false); diff --git a/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationConfigUITest.php b/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationConfigUITest.php new file mode 100644 index 0000000000000000000000000000000000000000..ed54b4527079e189541c7e85e7750b67222a9cb8 --- /dev/null +++ b/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationConfigUITest.php @@ -0,0 +1,47 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\content_translation\FunctionalJavascript; + +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; + +/** + * Tests that the content translation configuration javascript does't fail. + * + * @group content_translation + */ +class ContentTranslationConfigUITest extends WebDriverTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = ['content_translation', 'node']; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * Use the minimal profile. + * + * @var string + */ + protected $profile = 'standard'; + + /** + * Tests that the content translation configuration javascript does't fail. + */ + public function testContentTranslationConfigUI() { + $content_translation_manager = $this->container->get('content_translation.manager'); + $content_translation_manager->setEnabled('node', 'article', TRUE); + $this->rebuildContainer(); + + $admin = $this->drupalCreateUser([], NULL, TRUE); + $this->drupalLogin($admin); + $this->drupalGet('/admin/config/regional/content-language'); + $this->failOnJavaScriptErrors(); + } + +}