Skip to content

fix: prevent circular component references from crashing the editor#138

Merged
liamwalder merged 2 commits intodevelopfrom
fix/component-loops-form-layouts
Apr 9, 2026
Merged

fix: prevent circular component references from crashing the editor#138
liamwalder merged 2 commits intodevelopfrom
fix/component-loops-form-layouts

Conversation

@tristan-mouchet
Copy link
Copy Markdown
Collaborator

@tristan-mouchet tristan-mouchet commented Apr 7, 2026

Summary

Prevent circular component references from causing infinite recursion (500 error)
and making the editor unrecoverable. This can happen when adding a layout that
contains a component instance inside the component itself (or one of its descendants).

Changes

  • Add circular reference guard to resolveComponents() and resolveComponentsInLayers() using a visited-set to break infinite recursion
  • Block layout insertion inside a component when the layout contains a circular component reference
  • Disable drag/click interactions on circular components in the ElementLibrary

Test plan

  • Edit a component, add a layout that contains an instance of the same component — should show error toast
  • Verify normal layout insertion inside a component still works
  • Verify addinnon-circular components via click and drag still works
  • If circular data already exists in the DB, verify the page renders without 500 (graceful skip)

@liamwalder liamwalder merged commit 2e6e23f into develop Apr 9, 2026
3 checks passed
@liamwalder liamwalder deleted the fix/component-loops-form-layouts branch April 9, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Dragging a component into itself causes circular reference, 500 error and editor becomes unrecoverable

2 participants