diff --git a/CHANGELOG.md b/CHANGELOG.md index cec4b0f1641..8daf5aa05ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Fixed a bug where newly-selected elements weren’t being rendered correctly for relational fields set to the “Card grid” view mode. ([#18362](https://github.com/craftcms/cms/issues/18362)) - Fixed a bug where card previews weren’t getting updated when a selected field was removed from the field layout. - Fixed potential JavaScript errors that could occur if a disclosure menu’s trigger or target elements were missing. ([#18358](https://github.com/craftcms/cms/issues/18358)) +- Fixed a JavaScript error that occurred if a Matrix field’s label was hidden. ([#18366](https://github.com/craftcms/cms/issues/18366)) - Fixed an infinite recursion bug. ([#18363](https://github.com/craftcms/cms/issues/18363)) ## 5.9.5 - 2026-01-31 diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index c490e75f03c..63139873082 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -949,7 +949,7 @@ private function blockViewActionMenuItems(): array setTimeout(() => { const disclosureMenu = menu.data('disclosureMenu'); - disclosureMenu.on('show', () => { + disclosureMenu?.on('show', () => { let blocks = getBlocks(); let expandLabel, collapseLabel; if (blocks.is('.sel')) { @@ -1030,7 +1030,7 @@ private function copyAction(string $type, string $entrySelector): array if (!field.length) { setTimeout(() => { - menu.data('disclosureMenu').removeItem(btn[0]); + menu.data('disclosureMenu')?.removeItem(btn[0]); }, 1); return; } @@ -1057,7 +1057,7 @@ private function copyAction(string $type, string $entrySelector): array setTimeout(() => { const disclosureMenu = menu.data('disclosureMenu'); - disclosureMenu.on('show', () => { + disclosureMenu?.on('show', () => { const entries = getEntries(); let copyLabel; if ($(entries).is('.sel')) { @@ -1134,7 +1134,7 @@ private function bulkAction(string $entrySelector, string $activateJs, array $it if (!field.length) { setTimeout(() => { - menu.data('disclosureMenu').removeItem(btn[0]); + menu.data('disclosureMenu')?.removeItem(btn[0]); }, 1); return; } @@ -1147,7 +1147,7 @@ private function bulkAction(string $entrySelector, string $activateJs, array $it setTimeout(() => { const disclosureMenu = menu.data('disclosureMenu'); - disclosureMenu.on('show', () => { + disclosureMenu?.on('show', () => { disclosureMenu.toggleItem(btn[0], !!getEntries().length); }); }, 1);