Skip to content

Commit d78e3a8

Browse files
committed
move submit handler to be after deletion
1 parent 08a4cf3 commit d78e3a8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/lib/enhancers/github/GitHubIssueAppendEnhancer.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ export class GitHubIssueAppendEnhancer implements CommentEnhancer<GitHubIssueApp
6767
instance: OverTypeInstance | undefined
6868

6969
enhance(textArea: HTMLTextAreaElement, _spot: GitHubIssueAppendSpot): OverTypeInstance {
70-
this.registerSubmitHandler(textArea, _spot)
7170
prepareGitHubHighlighter()
7271
const overtypeContainer = modifyDOM(textArea)
7372
if (this.instance) {
7473
OverType.instances.delete(overtypeContainer)
75-
;(overtypeContainer as any).overTypeInstance = undefined
74+
; (overtypeContainer as any).overTypeInstance = undefined
7675
}
76+
this.registerSubmitHandler(textArea, _spot)
7777
const thing = new OverType(overtypeContainer, {
7878
...commonGitHubOptions,
7979
minHeight: '100px',
@@ -87,12 +87,14 @@ export class GitHubIssueAppendEnhancer implements CommentEnhancer<GitHubIssueApp
8787
oncePerRefresh('gh-issue-append-events', () => {
8888
document.addEventListener('click', (e) => {
8989
const target = e.target
90-
if (!target) return false
91-
const btn = (e.target as HTMLElement).closest('button')
92-
if (!btn) return false
93-
if (btn.textContent.trim() === 'Comment' || btn.matches('button[data-variant="primary"]')) {
94-
this.enhance(textArea, _spot)
95-
return true
90+
if (target) {
91+
const btn = (e.target as HTMLElement).closest('button')
92+
if (btn) {
93+
if (btn.textContent.trim() === 'Comment' || btn.matches('button[data-variant="primary"]')) {
94+
this.enhance(textArea, _spot)
95+
return true
96+
}
97+
}
9698
}
9799
return false
98100
})

0 commit comments

Comments
 (0)