fix: Note is sometimes updates while opening#268
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe MarkdownSerializePlugin now tags its programmatic Changes
Sequence Diagram(s)sequenceDiagram
participant UI as User
participant Editor as Lexical Editor
participant MDPlugin as MarkdownSerializePlugin
participant OnChange as OnChangePlugin
participant Sync as Serializer/onChanged
UI->>Editor: open note (user action)
Editor->>MDPlugin: effect triggers programmatic update
MDPlugin->>Editor: editor.update(..., { tag: "non-user-update" })
Editor->>OnChange: emit change event (includes tags)
OnChange->>OnChange: sees tags.has("non-user-update")
OnChange-->>Sync: (no call) — early return, skip syncValue/onChanged
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
f51ba0a to
8147907
Compare
53a897f to
34b863e
Compare
Closes #258
When user open note, the RichEditor component receive the note text as property.
The serializer plugin react on that as on update, and serialize the input.
In case the input and output are different the change is triggered.
The output may be different because of different implementation of markdown parser/serializer.
It happens mostly when markdown contains advanced constructions like title for link in your example.
In scope of this PR we introduce the code to prevent serialization of any input except user input via keyboard into editor component.
Technically we mark any other inputs via special tag and skip serialization for changes with that tag.
The root problem: When we receive the external value - we update editor, this trigger the OnChangePlugin witch update external value and then note updated. But value is changed not user initiated. I suggests ignore this update and not update note in this case
The current flow in
MarkdownSerializePlugin:External value update:
OnChangePlugin triggers:
User made no real changes, but the note was updated.
Fix:
Tag editor updates made by us in useEffect and ignore them in
OnChangePlugin.Updated flow in
MarkdownSerializePlugin:External value changed:
OnChangePlugin triggers:
Summary by CodeRabbit