fix(ui): harden issue comment editor sync
This commit is contained in:
@@ -364,6 +364,19 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
|
||||
return map;
|
||||
}, [mentions]);
|
||||
|
||||
const setEditorRef = useCallback((instance: MDXEditorMethods | null) => {
|
||||
ref.current = instance;
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
if (valueRef.current !== latestValueRef.current) {
|
||||
// Re-apply the latest controlled value once MDXEditor exposes its imperative API.
|
||||
echoIgnoreMarkdownRef.current = valueRef.current;
|
||||
instance.setMarkdown(valueRef.current);
|
||||
latestValueRef.current = valueRef.current;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const filteredMentions = useMemo<AutocompleteOption[]>(() => {
|
||||
if (!mentionState) return [];
|
||||
const q = mentionState.query.trim().toLowerCase();
|
||||
@@ -798,7 +811,7 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
|
||||
onPasteCapture={handlePasteCapture}
|
||||
>
|
||||
<MDXEditor
|
||||
ref={ref}
|
||||
ref={setEditorRef}
|
||||
markdown={value}
|
||||
placeholder={placeholder}
|
||||
onChange={(next) => {
|
||||
|
||||
Reference in New Issue
Block a user