-
Notifications
You must be signed in to change notification settings - Fork 123
Description
Summary
When a collection item (or asset) is referenced via a relation widget, it should not be possible to delete or rename that item without addressing existing references. This would prevent broken relations and invalid content states.
Problem statement
Currently, Sveltia CMS allows users to rename or delete items that are referenced elsewhere via a relation widget. This can easily lead to broken references and runtime errors.
Example scenario
- Collection Categories
- Collection Products
- Products reference categories using a
relationwidget (based on the category filename)
If a user renames or deletes a category:
- Existing product entries still reference the old filename
- The reference now points to a non-existent item
- This results in broken data and errors in the CMS and/or frontend
This is especially problematic in larger projects where editors may not be aware of all downstream dependencies.
Proposed solutions
Option 1: Blocking with explicit warning (minimum safeguard)
When a user attempts to rename or delete an item that is still referenced:
-
Show a very visible warning
-
Clearly list:
- Which collections reference this item
- How many entries are affected (ideally with links)
-
Require explicit confirmation before proceeding
This at least makes the action intentional and informed.
Option 2: Hard prevention (recommended)
Disallow renaming or deleting items that are referenced via a relation widget.
This could be a feature that is enabled through a config setting on a relation field.
Possible UX:
-
Disable the delete/rename action
-
Show an explanation such as:
“This item is currently referenced by 12 product entries and cannot be deleted or renamed.”
This guarantees referential integrity and avoids accidental breakage entirely.
Extended ideas / enhancements
1. Reference awareness UI
Expose references directly in the editor UI:
- Show a “Referenced by” section on an entry
- Display linked items that depend on it
This improves transparency and editor confidence.
2. Optional cascading updates
For renaming (not deletion), an optional advanced feature:
- Automatically update all references when a filename changes
- Similar to “rename symbol” in code editors
This could be opt-in per project or per collection.
Broader scope: assets and file references
The same concept applies beyond collection items.
Images and files
-
If an image or file is referenced by one or more entries:
- Prevent deletion, or
- Warn clearly and list all referencing entries
This would:
- Prevent broken media links
- Avoid invisible content regressions
- Align CMS behavior with database-like referential integrity
Why this matters
- Prevents silent data corruption
- Reduces editor errors in multi-author environments
- Makes Sveltia CMS safer for larger, more complex content models
- Brings CMS behavior closer to modern schema-aware systems