-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WEB-6037] fix: workitem description input initial load #8617
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
base: preview
Are you sure you want to change the base?
[WEB-6037] fix: workitem description input initial load #8617
Conversation
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
📝 WalkthroughWalkthroughThe change adds content change detection to a rich text editor by introducing a ref that tracks the last saved content state, allowing the component to skip processing onChange events when content hasn't actually changed, thereby optimizing unnecessary state updates and debounced saves. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes the “unsaved changes” browser alert triggered on initial open/expand of a work item peek view by preventing autosave/dirty-state logic from firing due to editor normalization on init.
Changes:
- Track a
lastSavedContentref to represent the currently-saved HTML. - Normalize empty initial values to
"<p></p>"consistently during reset/init. - Skip
onChangehandling when emitted HTML equals the last saved HTML (to avoid false dirty state on init).
Comments suppressed due to low confidence (1)
apps/web/core/components/editor/rich-text/description-input/root.tsx:235
- The early return when
description_html === lastSavedContent.currentskips updating the react-hook-form field and doesn’t cancel any already-scheduleddebouncedFormSave(). If a user makes an edit (scheduling a debounced save) and then undoes back to the last-saved content, this handler will return, leaving the form state on the edited value and allowing the pending debounced save to persist the wrong content. Consider always syncing the form state, and when the content matcheslastSavedContent.current, cancel the debounced save and reset the unsaved/submitting flags instead of returning before state updates.
onChange={(_description, description_html, options) => {
// Skip if content hasn't actually changed (handles editor normalization on init)
if (description_html === lastSavedContent.current) return;
setIsSubmitting("submitting");
onChange(description_html);
setValue("isMigrationUpdate", options?.isMigrationUpdate ?? false);
hasUnsavedChanges.current = true;
debouncedFormSave();
Description
This PR resolves the browser alert that appears when opening or expanding a work item peek view without making any edits.
Type of Change
Summary by CodeRabbit
Bug Fixes