-
-
Notifications
You must be signed in to change notification settings - Fork 213
Open
Description
Bug Report 🐛
Current Behavior
All the three editor containers (ie TemplateMarkdown, TemplateModel, AgreementData) call the main state setter twice per keystroke. The useUndoRedo hook already calls onSync (the rebuild triggering function) internally but then the handleChange function calls it again via setTemplateMarkdown(val) which is a redundancy issue causing two rebuilds per change/keystroke.
Understanding the flow of execution:
- User types or makes a change in an editor (say TemplateMarkdown)
handleChange()is triggered inside that componentsetValue(val)insideuseUndoRedohook runsonSync()is called and rebuild() is triggered automatically viasetTemplateMarkdownas it was passed as argument inonSynchandleChange()again causes another rebuild for that same keystroke
const handleChange = (val: string | undefined) => {
if (val !== undefined) {
updateEditorActivity("markdown");
setValue(val);
void setTemplateMarkdown(val);
}
};Expected Behavior
Each keystroke should trigger only one rebuild, not two.
Possible Solution
Remove the redundant explicit setter calls from handleChange() in:
- TemplateMarkdown.tsx
- TemplateModel.tsx
- AgreementData.tsx
Impact:
This will eliminate unnecessary duplicate rebuilds on every keystroke and reduce redundant Zustand state updates!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels