Skip to content

fix: fix/prevent-class-name-clashing - #7

Merged
erickzanardo merged 5 commits into
mainfrom
fix/prevent-class-name-clashing
Oct 16, 2026
Merged

erickzanardo merged 5 commits into
mainfrom
fix/prevent-class-name-clashing

Conversation

@erickzanardo

Copy link
Copy Markdown
Member

Description

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

final ComponentRepository _componentRepository;
final ProjectRepository _projectRepository;

Future<void> _onStarted(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until this handler emits, takenClassNames is empty, so a child added or renamed in that window skips the check. Nothing re-checks it after the names load or on save. Re-validate the whole tree against takenClassNames after loading, or check again in the save handler before writing the code, so this window and existing clashes get caught.

final taken = await _loadTakenClassNames();
saved = saved.copyWith(takenClassNames: taken);
if (component.generatedClassNames.any(taken.contains)) {
emit(saved.copyWith(status: ComponentEditorStatus.classConflict));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a classConflict save, hasChanges is false. If the clash is fixed by renaming the other component, Cmd/Ctrl+S here hits the !state.hasChanges early return, and the code is never generated until the user makes a dummy edit. Let saves go through while status == classConflict, or don't count the save as done for code generation.

ComponentEditorStatus.classConflict =>
'Saved, but the code was not generated: other components also '
'generate ${state.conflictingClassNames.join(', ')}. '
'Rename the clashing children',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the root class is one of conflictingClassNames (for example, AB and a_b both created before this check existed), renaming children won't fix it, and the root can't be renamed here. When the root clashes, tell the user to rename or delete the other component instead.

@erickzanardo
erickzanardo merged commit 1580ba8 into main Oct 16, 2026
7 checks passed
@erickzanardo
erickzanardo deleted the fix/prevent-class-name-clashing branch October 16, 2026 21:23
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.

1 participant