-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix activity editor #9165
Fix activity editor #9165
Conversation
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.
PR Summary
This PR refactors the activity editor by separating title and body management concerns, focusing on a more specialized rich text editing implementation for activities.
- Renamed
RichTextEditor
toActivityRichTextEditor
in/packages/twenty-front/src/modules/activities/components/ActivityRichTextEditor.tsx
and removed title-related functionality - Added new hook
useReplaceActivityBlockEditorContent
with potential JSON parsing vulnerability and incorrectreplaceBlocks
implementation - Added
ActivityRichTextEditorChangeOnActivityIdEffect
component to handle content updates, though it may have race condition issues - Removed
activityBodyFamilyState
andactivityTitleHasBeenSetFamilyState
for simpler state management - Eliminated drag bug workaround that used debounced state setter
4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
const content = isNonEmptyString(activityInStore?.body) | ||
? JSON.parse(activityInStore?.body) | ||
: [{ type: 'paragraph', content: '' }]; |
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.
style: JSON.parse could throw for malformed JSON. Wrap in try/catch and fallback to empty paragraph
replaceBlockEditorContent(activityId); | ||
setCurrentActivityId(activityId); | ||
} |
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.
logic: Potential race condition between replaceBlockEditorContent and setCurrentActivityId. Consider using an async/await pattern or ensuring replaceBlockEditorContent completes before updating state.
const { replaceBlockEditorContent } = | ||
useReplaceActivityBlockEditorContent(editor); | ||
|
||
const [currentActivityId, setCurrentActivityId] = useState(activityId); |
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.
style: Initial state could be unnecessary since the effect already handles the first render. Consider removing the state and tracking changes differently.
No description provided.