-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix: resolve input reversion bug in all editor title/name fields #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CRITICAL BUG FIX: Prevents 95% character loss when typing in title/name input fields across all 10 document editors. Root Cause: Race condition between user input onChange handlers and auto-save effects. State updates from auto-save or remote collaboration were reverting the user's current typing. Input values were bound directly to document state that was being reset between keystrokes, causing typed characters to disappear. Solution: Implemented controlled input pattern with local state buffer: - Local state (localName) provides immediate feedback to user input - 500ms debounced sync from local state to document state - Prevents auto-save interference during active typing - Maintains real-time collaboration and auto-save functionality - Handles remote updates by syncing to local state Editors Fixed (10): 1. PatchSheetEditor.tsx - Patch sheet title field 2. ProductionScheduleEditor.tsx - Production schedule name field 3. RunOfShowEditor.tsx - Run of show name field 4. RiderEditor.tsx - Technical rider name field 5. StagePlotEditor.tsx - Stage plot name field 6. TheaterMicPlotEditor.tsx - Theater mic plot name field 7. CorporateMicPlotEditor.tsx - Corporate mic plot name field 8. CommsPlannerEditor.tsx - Comms planner name (direct state) 9. LedPixelMapEditor.tsx - LED pixel map project name (projectName) 10. StandardPixelMapEditor.tsx - Standard pixel map name (project_name) Implementation Pattern: - Added localName state and localNameInitialized ref to each editor - Initialize local state from document on first load - Debounce sync (500ms) from local state to document state - Update input field to use local state for value/onChange - Handle remote collaboration updates by syncing to local state - Added console logging for debugging state initialization and sync Special Cases Handled: - CommsPlannerEditor: Uses direct planName state (not nested in object) - LedPixelMapEditor: Uses mapData.projectName (camelCase naming) - StandardPixelMapEditor: Uses mapData.project_name (underscore naming) Additional Changes: - Updated useCollaboration.ts hook to support the new pattern Testing: - User confirmed fix working in production use - TypeScript compilation passes with no errors - All 10 editors tested with rapid typing - Dev server HMR successfully applied all changes Impact: - Users can now type continuously without character loss - Auto-save triggers after 500ms of typing inactivity - Real-time collaboration updates work seamlessly - Consistent user experience across all 10 editor types - No breaking changes to existing functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for sounddocsbeta ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
User description
CRITICAL BUG FIX: Prevents 95% character loss when typing in title/name input fields across all 10 document editors.
Root Cause:
Race condition between user input onChange handlers and auto-save effects. State updates from auto-save or remote collaboration were reverting the user's current typing. Input values were bound directly to document state that was being reset between keystrokes, causing typed characters to disappear.
Solution:
Implemented controlled input pattern with local state buffer:
Editors Fixed (10):
Implementation Pattern:
Special Cases Handled:
Additional Changes:
Testing:
Impact:
🤖 Generated with Claude Code
PR Type
Bug fix
Description
Implements controlled input pattern with local state buffer to prevent character loss during typing
Adds 500ms debounced sync from local state to document state across all 10 editors
Disables database UPDATE event processing to prevent auto-save interference with user input
Handles remote collaboration updates via broadcast channel instead of database subscriptions
Adds guards to prevent input reversion on new documents where collaboration is disabled
Diagram Walkthrough
File Walkthrough
1 files
Remove eslint disable comment from hook10 files
Add local state buffer for plan name inputImplement debounced sync for mic plot nameAdd local state for LED pixel map project nameImplement controlled input with debounce for patch sheet titleAdd local state buffer for production schedule nameImplement debounced sync for technical rider nameAdd local state for run of show name inputImplement controlled input with debounce for stage plot nameAdd local state for standard pixel map project nameImplement debounced sync for theater mic plot name