diff --git a/src/lib/enhancers/github/GitHubPrAppendEnhancer.tsx b/src/lib/enhancers/github/GitHubPrAppendEnhancer.tsx index 9321046..4499b21 100644 --- a/src/lib/enhancers/github/GitHubPrAppendEnhancer.tsx +++ b/src/lib/enhancers/github/GitHubPrAppendEnhancer.tsx @@ -56,12 +56,19 @@ export class GitHubPrAppendEnhancer implements CommentEnhancer { + if (textArea.value === '') { + overtype.updatePreview() + } + }) + listenForEmpty.observe(textArea, { attributes: true, characterData: true }) + return overtype } tableUpperDecoration(spot: GitHubPrAppendSpot): React.ReactNode { diff --git a/src/lib/registries.ts b/src/lib/registries.ts index 8a81c85..6d3fb38 100644 --- a/src/lib/registries.ts +++ b/src/lib/registries.ts @@ -129,9 +129,15 @@ export class TextareaRegistry { this.sendEvent('ENHANCED', enhanced) } + private cleanupOvertype(overtype: OverTypeInstance) { + const container = overtype.element + OverType.instances.delete(container) + ;(container as any).overTypeInstance = undefined + } unregisterDueToModification(textarea: HTMLTextAreaElement): void { const enhanced = this.textareas.get(textarea) if (enhanced) { + this.cleanupOvertype(enhanced.overtype) this.sendEvent('DESTROYED', enhanced) this.textareas.delete(textarea) }