The root cause: handleMentionSelect set draft to mention HTML, but the subsequent MentionInput.onInput event fired with plain text (after the programmatic DOM insert) and overwrote the draft. Solution: replace pendingSyncRef trick with a clean isUserInputRef flag. - useEffect: if getPlainText(el) === value, DOM already correct (skip). Mark isUserInputRef = false so next useEffect skips caret restore. - handleInput: always set isUserInputRef = true before calling onChange. This eliminates the pendingSyncRef/__mentionSkipSync global flag mess entirely. |
||
|---|---|---|
| .. | ||
| app | ||
| assets | ||
| client | ||
| components | ||
| contexts | ||
| hooks | ||
| lib | ||
| App.css | ||
| App.tsx | ||
| index.css | ||
| main.tsx | ||