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
56
56
enhance ( textArea : HTMLTextAreaElement , _spot : GitHubPrAppendSpot ) : OverTypeInstance {
57
57
prepareGitHubHighlighter ( )
58
58
const overtypeContainer = modifyDOM ( textArea )
59
- return new OverType ( overtypeContainer , {
59
+ const overtype = new OverType ( overtypeContainer , {
60
60
...commonGitHubOptions ,
61
61
minHeight : '102px' ,
62
62
padding : 'var(--base-size-8)' ,
63
63
placeholder : 'Add your comment here...' ,
64
64
} ) [ 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
65
72
}
66
73
67
74
tableUpperDecoration ( spot : GitHubPrAppendSpot ) : React . ReactNode {
Original file line number Diff line number Diff line change @@ -129,9 +129,15 @@ export class TextareaRegistry {
129
129
this . sendEvent ( 'ENHANCED' , enhanced )
130
130
}
131
131
132
+ private cleanupOvertype ( overtype : OverTypeInstance ) {
133
+ const container = overtype . element
134
+ OverType . instances . delete ( container )
135
+ ; ( container as any ) . overTypeInstance = undefined
136
+ }
132
137
unregisterDueToModification ( textarea : HTMLTextAreaElement ) : void {
133
138
const enhanced = this . textareas . get ( textarea )
134
139
if ( enhanced ) {
140
+ this . cleanupOvertype ( enhanced . overtype )
135
141
this . sendEvent ( 'DESTROYED' , enhanced )
136
142
this . textareas . delete ( textarea )
137
143
}
You can’t perform that action at this time.
0 commit comments