File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,19 @@ export class GitHubPrAppendEnhancer implements CommentEnhancer<GitHubPrAppendSpo
5656 enhance ( textArea : HTMLTextAreaElement , _spot : GitHubPrAppendSpot ) : OverTypeInstance {
5757 prepareGitHubHighlighter ( )
5858 const overtypeContainer = modifyDOM ( textArea )
59- return new OverType ( overtypeContainer , {
59+ const overtype = new OverType ( overtypeContainer , {
6060 ...commonGitHubOptions ,
6161 minHeight : '102px' ,
6262 padding : 'var(--base-size-8)' ,
6363 placeholder : 'Add your comment here...' ,
6464 } ) [ 0 ] !
65+ const listenForEmpty = new MutationObserver ( ( ) => {
66+ if ( textArea . value === '' ) {
67+ overtype . updatePreview ( )
68+ }
69+ } )
70+ listenForEmpty . observe ( textArea , { attributes : true , characterData : true } )
71+ return overtype
6572 }
6673
6774 tableUpperDecoration ( spot : GitHubPrAppendSpot ) : React . ReactNode {
Original file line number Diff line number Diff line change @@ -129,9 +129,15 @@ export class TextareaRegistry {
129129 this . sendEvent ( 'ENHANCED' , enhanced )
130130 }
131131
132+ private cleanupOvertype ( overtype : OverTypeInstance ) {
133+ const container = overtype . element
134+ OverType . instances . delete ( container )
135+ ; ( container as any ) . overTypeInstance = undefined
136+ }
132137 unregisterDueToModification ( textarea : HTMLTextAreaElement ) : void {
133138 const enhanced = this . textareas . get ( textarea )
134139 if ( enhanced ) {
140+ this . cleanupOvertype ( enhanced . overtype )
135141 this . sendEvent ( 'DESTROYED' , enhanced )
136142 this . textareas . delete ( textarea )
137143 }
You can’t perform that action at this time.
0 commit comments