Skip to content

Commit 89763c1

Browse files
committed
fixup edit so that it works for issues and for PRs.
1 parent bce5f38 commit 89763c1

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/lib/enhancers/github/githubEditComment.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ export class GitHubEditCommentEnhancer implements CommentEnhancer<GitHubEditComm
2323
return null
2424
}
2525

26-
// Only enhance textareas that are within the issue/PR body editing container
27-
const bodyContainer = textarea.closest('.react-issue-body')
28-
if (!bodyContainer) {
26+
// Only enhance textareas that are for editing issue/PR body
27+
const isIssueBodyEdit = textarea.closest('.react-issue-body')
28+
const isPRBodyEdit = textarea.id?.match(/^issue-\d+-body$/) || textarea.name === 'pull_request[body]'
29+
30+
if (!isIssueBodyEdit && !isPRBodyEdit) {
2931
return null
3032
}
3133

tests/lib/enhancers/github.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,15 @@ describe('github', () => {
241241
expect(enhancements(document, window)).toMatchInlineSnapshot(`
242242
[
243243
{
244-
"for": "id=issue-3429313834-body name=pull_request[body] className=js-comment-field js-paste-markdown js-task-list-field js-quick-submit js-size-to-fit size-to-fit js-session-resumable CommentBox-input FormControl-textarea js-saved-reply-shortcut-comment-field focus-visible",
245-
"spot": "NO_SPOT",
244+
"for": "id=issue-3429313834-body name=pull_request[body] className=js-comment-field js-paste-markdown js-task-list-field js-quick-submit js-size-to-fit size-to-fit js-session-resumable CommentBox-input FormControl-textarea js-saved-reply-shortcut-comment-field focus-visible overtype-input",
245+
"spot": {
246+
"type": "GH_EDIT_COMMENT",
247+
"unique_key": "github.com:diffplug/gitcasso:58:edit-body",
248+
},
249+
"title": "N/A",
250+
"upperDecoration": <span>
251+
N/A
252+
</span>,
246253
},
247254
{
248255
"for": "id=new_comment_field name=comment[body] className=js-comment-field js-paste-markdown js-task-list-field js-quick-submit FormControl-textarea CommentBox-input js-size-to-fit size-to-fit js-session-resumable js-saved-reply-shortcut-comment-field overtype-input",

0 commit comments

Comments
 (0)