Skip to content

Commit 72e78f4

Browse files
authored
[4.0] Fix categories accordion (#35093)
1 parent abfe91f commit 72e78f4

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

build/media_source/com_categories/joomla.asset.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
"description": "Joomla CMS",
66
"license": "GPL-2.0-or-later",
77
"assets": [
8+
{
9+
"name": "com_categories.shared-categories-accordion",
10+
"type": "preset",
11+
"dependencies": [
12+
"com_categories.shared-categories-accordion#style",
13+
"com_categories.shared-categories-accordion#script"
14+
]
15+
},
816
{
917
"name": "com_categories.shared-categories-accordion.es5",
1018
"type": "script",

build/media_source/com_categories/js/shared-categories-accordion.es6.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const handleCategoryToggleButtonClick = ({ currentTarget }) => {
3838
),
3939
);
4040

41-
const target = button.nextElementSibling;
41+
const { categoryId } = button.dataset;
42+
const target = document.getElementById(`category-${categoryId}`);
4243
target.toggleAttribute('hidden');
4344
};
4445

components/com_content/tmpl/categories/default.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
2020
$wa = $this->document->getWebAssetManager();
2121
$wa->getRegistry()->addExtensionRegistryFile('com_categories');
22-
$wa->useStyle('com_categories.shared-categories-accordion');
23-
$wa->useScript('com_categories.shared-categories-accordion');
22+
$wa->usePreset('com_categories.shared-categories-accordion');
2423

2524
?>
2625
<div class="com-content-categories categories-list">

components/com_content/tmpl/categories/default_items.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<button
3535
type="button"
3636
id="category-btn-<?php echo $item->id; ?>"
37+
data-category-id="<?php echo $item->id; ?>"
3738
class="btn btn-secondary btn-sm"
3839
aria-expanded="false"
3940
aria-label="<?php echo Text::_('JGLOBAL_EXPAND_CATEGORIES'); ?>"

0 commit comments

Comments
 (0)