@@ -55,6 +55,8 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
5555 const isAdjustingMobileCursor = useRef ( false )
5656 const note = useRef ( controller . item )
5757
58+ const [ isPendingLocalPropagation , setIsPendingLocalPropagation ] = useState ( false )
59+
5860 const tabObserverDisposer = useRef < Disposer > ( )
5961 const mutationObserver = useRef < MutationObserver | null > ( null )
6062
@@ -79,27 +81,40 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
7981 throw Error ( 'Editor received changes for non-current note' )
8082 }
8183
82- if (
83- isPayloadSourceRetrieved ( source ) ||
84- editorText == undefined ||
85- updatedNote . editorIdentifier !== note . current . editorIdentifier ||
86- updatedNote . noteType !== note . current . noteType
87- ) {
88- setEditorText ( updatedNote . text )
84+ if ( ! isPendingLocalPropagation ) {
85+ if (
86+ isPayloadSourceRetrieved ( source ) ||
87+ editorText == undefined ||
88+ updatedNote . editorIdentifier !== note . current . editorIdentifier ||
89+ updatedNote . noteType !== note . current . noteType
90+ ) {
91+ setEditorText ( updatedNote . text )
92+ }
8993 }
9094
9195 note . current = updatedNote
9296 } )
9397
9498 return disposer
95- } , [ controller , editorText , controller . item . uuid , controller . item . editorIdentifier , controller . item . noteType ] )
99+ } , [
100+ controller ,
101+ editorText ,
102+ controller . item . uuid ,
103+ controller . item . editorIdentifier ,
104+ controller . item . noteType ,
105+ isPendingLocalPropagation ,
106+ ] )
96107
97108 const onTextAreaChange : ChangeEventHandler < HTMLTextAreaElement > = ( { currentTarget } ) => {
98109 const text = currentTarget . value
99110
100111 setEditorText ( text )
101112
102- void controller . saveAndAwaitLocalPropagation ( { text : text , isUserModified : true } )
113+ setIsPendingLocalPropagation ( true )
114+
115+ void controller . saveAndAwaitLocalPropagation ( { text : text , isUserModified : true } ) . then ( ( ) => {
116+ setIsPendingLocalPropagation ( false )
117+ } )
103118 }
104119
105120 const onContentFocus = useCallback ( ( ) => {
0 commit comments