diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php
index 22bade6..4250ff0 100644
--- a/core/modules/system/src/Controller/SystemController.php
+++ b/core/modules/system/src/Controller/SystemController.php
@@ -426,11 +426,14 @@ public static function setLinkActiveClass(array $element, array $context) {
       // "active" class.
       if ($is_active) {
         $class = $node->getAttribute('class');
-        if (strlen($class) > 0) {
-          $class .= ' ';
+
+        // Make sure the active class is only added once to the element.
+        $classes = explode(' ', $class);
+        if (!in_array('active', $classes)) {
+          $classes[] = 'active';
+          $class = implode(' ', $classes);
+          $node->setAttribute('class', trim($class));
         }
-        $class .= 'active';
-        $node->setAttribute('class', $class);
 
         // Get the updated tag.
         $updated_tag = $dom->saveXML($node, LIBXML_NOEMPTYTAG);
