Skip to content

fix(scene): preserve prefab root on delete - #896

Open
bofeng-song wants to merge 1 commit into
cocos:mainfrom
bofeng-song:fix/prefab-root-delete
Open

fix(scene): preserve prefab root on delete#896
bofeng-song wants to merge 1 commit into
cocos:mainfrom
bofeng-song:fix/prefab-root-delete

Conversation

@bofeng-song

@bofeng-song bofeng-song commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Problem

Deleting a select-all hierarchy in prefab editing mode could include the prefab root. CLI removed that root together with the selected nodes, and the editor later displayed anonymous Empty Node entries instead of retaining the prefab root and its name.

Creator keeps the opened prefab asset root in this case.

Cause

NodeService.delete() did not distinguish the current prefab editor root from regular nodes. A delete request targeting the root therefore removed the complete prefab hierarchy.

Fix

  • Reject deletion when the current editor is in prefab mode and the target node UUID matches the opened prefab root UUID.
  • Continue allowing child nodes to be deleted normally.
  • Add a regression test that deletes a child and then attempts to delete the prefab root, verifying that the root path and name remain unchanged.

Validation

  • npx tsc --noEmit --pretty false passes.
  • The prefab integration suite could not start locally because the installed gl native module was built for a different Node ABI.

@bofeng-song
bofeng-song requested review from doommm and knoxHuang and removed request for knoxHuang August 31, 2026 03:15
@bofeng-song bofeng-song reopened this Aug 31, 2026
@bofeng-song bofeng-song reopened this Aug 31, 2026
@bofeng-song
bofeng-song force-pushed the fix/prefab-root-delete branch from dc648cc to 614de19 Compare August 31, 2026 06:06
@bofeng-song
bofeng-song force-pushed the fix/prefab-root-delete branch from 614de19 to 506ab86 Compare August 31, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants