diff --git a/administrator/templates/atum/joomla.asset.json b/administrator/templates/atum/joomla.asset.json index 6f665b7fd556c..0ca417266ccbd 100644 --- a/administrator/templates/atum/joomla.asset.json +++ b/administrator/templates/atum/joomla.asset.json @@ -26,12 +26,19 @@ "type": "style", "uri": "", "class": "LangActiveAssetItem", - "client": "administrator" + "client": "administrator", + "dependencies": [ + "template.active" + ] }, { "name": "template.user", "type": "style", - "uri": "user.css" + "uri": "user.css", + "dependencies": [ + "template.active", + "template.active.language" + ] }, { "name": "template.atum", diff --git a/libraries/src/WebAsset/WebAssetManager.php b/libraries/src/WebAsset/WebAssetManager.php index ab6a9578ca5a8..920d4343b1733 100644 --- a/libraries/src/WebAsset/WebAssetManager.php +++ b/libraries/src/WebAsset/WebAssetManager.php @@ -750,7 +750,8 @@ protected function enableDependencies(string $type = null, WebAssetItem $asset = // Set dependency state only when it is inactive, to keep a manually activated Asset in their original state if (empty($this->activeAssets[$depType][$depItem->getName()])) { - $this->activeAssets[$depType][$depItem->getName()] = static::ASSET_STATE_DEPENDENCY; + // Add the dependency at the top of the list of active assets + $this->activeAssets[$depType] = [$depItem->getName() => static::ASSET_STATE_DEPENDENCY] + $this->activeAssets[$depType]; } } } @@ -819,6 +820,9 @@ function ($el) { ) ); + // Reverse, to start from a last enabled and move up to a first enabled, this helps to maintain an original sorting + $emptyIncoming = array_reverse($emptyIncoming); + // Loop through, and sort the graph while ($emptyIncoming) { @@ -935,22 +939,19 @@ protected function getConnectionsGraph(array $assets): array { $name = $asset->getName(); - // Outgoing nodes + // Initialise an array for outgoing nodes of the asset $graphOutgoing[$name] = []; - foreach ($asset->getDependencies() as $depName) - { - $graphOutgoing[$name][$depName] = $depName; - } - - // Incoming nodes + // Initialise an array for incoming nodes of the asset if (!\array_key_exists($name, $graphIncoming)) { $graphIncoming[$name] = []; } + // Collect an outgoing/incoming nodes foreach ($asset->getDependencies() as $depName) { + $graphOutgoing[$name][$depName] = $depName; $graphIncoming[$depName][$name] = $name; } } diff --git a/templates/cassiopeia/joomla.asset.json b/templates/cassiopeia/joomla.asset.json index f9934be6d4bab..cb880f9c1622f 100644 --- a/templates/cassiopeia/joomla.asset.json +++ b/templates/cassiopeia/joomla.asset.json @@ -32,12 +32,19 @@ "name": "template.active.language", "type": "style", "uri": "", - "class": "LangActiveAssetItem" + "class": "LangActiveAssetItem", + "dependencies": [ + "template.active" + ] }, { "name": "template.user", "type": "style", - "uri": "user.css" + "uri": "user.css", + "dependencies": [ + "template.active", + "template.active.language" + ] }, { "name": "template.cassiopeia.googlefont", @@ -66,7 +73,9 @@ "name": "template.user", "type": "script", "uri": "user.js", - "dependencies": ["template.cassiopeia"] + "dependencies": [ + "template.active" + ] }, {