Skip to content

Conversation

@nullcoder
Copy link
Owner

Summary

  • Move duplicate filename validation from FileEditor to MultiFileEditor for better separation of concerns
  • Update validation to show errors without blocking input (improved UX)
  • Add onValidationChange callback for parent components to control form submission

Problem

The current implementation validates duplicate filenames at the FileEditor level, which creates coupling issues since FileEditor needs to know about all other files. This also blocks user input when duplicates are detected, creating a poor user experience.

Solution

This PR refactors the validation logic:

  1. MultiFileEditor now tracks duplicate filenames (since it owns the file list)
  2. FileEditor receives an error prop for external validation messages
  3. Users can type freely while seeing validation errors in real-time
  4. Parent components can use onValidationChange callback to enable/disable form submission

Changes

  • FileEditor now accepts an error prop for external validation errors
  • MultiFileEditor tracks duplicate filenames and passes errors down to affected files
  • Added onValidationChange callback to notify parent components of validation state
  • Updated tests to reflect new validation behavior
  • Marked MultiFileEditor as completed in TODO.md

Test plan

  • Multi-file editor tests pass
  • File editor still validates local errors (empty names, invalid characters)
  • Duplicate filenames show error messages on affected files
  • Summary error message appears when duplicates exist
  • Validation state callback works correctly

🤖 Generated with Claude Code

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 7, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ghostpaste e5b0ac9 Visit preview Jun 07 2025, 02:42 AM

## Summary
- Move duplicate filename validation from FileEditor to MultiFileEditor
- Update validation to show errors without blocking input (better UX)
- Add onValidationChange callback for parent components
- Update tests to reflect new validation behavior

## Changes
- FileEditor now accepts an `error` prop for external validation errors
- MultiFileEditor tracks duplicate filenames and passes errors down
- Users can type freely while seeing validation errors in real-time
- Form submission can be blocked at parent level based on validation state

This provides a cleaner separation of concerns where MultiFileEditor owns
the list of files and validates uniqueness, while FileEditor only handles
local validation (empty names, invalid characters).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nullcoder nullcoder force-pushed the fix/duplicate-filename-validation branch from 9eb7d38 to 230338e Compare June 7, 2025 02:13
nullcoder and others added 2 commits June 6, 2025 19:25
- Simplify test assertions to be less brittle
- Use fireEvent.change for reliable input simulation
- Fix auto-detect language test to properly verify functionality
- All tests now pass without warnings

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@nullcoder nullcoder merged commit 60c5cb4 into main Jun 7, 2025
1 check was pending
@nullcoder nullcoder deleted the fix/duplicate-filename-validation branch June 7, 2025 02:41
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