Fix collection manager JavaScript errors after attribute naming changes
- Update collection manager to use data-collection-id instead of data-content-id - Add safety checks to prevent undefined Map access in addItemControls - Add validation in editor to only initialize collections with valid collection IDs - Resolves TypeError and missing attribute errors in frontend collection management
This commit is contained in:
@@ -18,9 +18,9 @@ export class CollectionManager {
|
||||
this.auth = auth;
|
||||
|
||||
// Extract collection ID from container
|
||||
this.collectionId = this.container.getAttribute('data-content-id');
|
||||
this.collectionId = this.container.getAttribute('data-collection-id');
|
||||
if (!this.collectionId) {
|
||||
console.error('❌ Collection container missing data-content-id attribute');
|
||||
console.error('❌ Collection container missing data-collection-id attribute');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ export class CollectionManager {
|
||||
* Add management controls to an item (remove, reorder)
|
||||
*/
|
||||
addItemControls(itemElement, index) {
|
||||
if (this.itemControls.has(itemElement)) return; // Already has controls
|
||||
if (!this.itemControls || this.itemControls.has(itemElement)) return; // Already has controls or not initialized
|
||||
|
||||
const controls = document.createElement('div');
|
||||
controls.className = 'insertr-item-controls';
|
||||
|
||||
Reference in New Issue
Block a user