diff options
author | cloudchamb3r <jizon0123@protonmail.com> | 2024-10-17 14:34:39 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 13:34:39 +0800 |
commit | c1023b97aa217cda357953d3ceb42b8cf058d904 (patch) | |
tree | b774e098d1dde248eee1d819948c400a16d89694 | |
parent | 7e0fd4c20800dc0323e4eb3cfdcbdf81e4ecb333 (diff) | |
download | gitea-c1023b97aa217cda357953d3ceb42b8cf058d904.tar.gz gitea-c1023b97aa217cda357953d3ceb42b8cf058d904.zip |
[v1.22 backport] Fix null errors on conversation holder (#32258) (#32266) (#32282)
Backport #32266
fix #32258
Errors in the issue was due to unhandled null check. so i fixed it.
### Detailed description for Issue & Fix
To reproduce that issue, the comment must be deleted on Conversation
tab.
#### Before Delete
<img width="1032" alt="image"
src="https://github.com/user-attachments/assets/72df61ba-7db6-44c9-bebc-ca1178dd27f1">
#### After Delete (AS-IS)
<img width="1010" alt="image"
src="https://github.com/user-attachments/assets/36fa537e-4f8e-4535-8d02-e538c50f0dd8">
gitea already have remove logic for `timeline-item-group`, but because
of null ref exception the later logic that removes `timeline-item-group`
could be not be called correctly.
-rw-r--r-- | web_src/js/features/repo-issue.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index 519db34934..6cd254dd81 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -188,14 +188,17 @@ export function initRepoIssueCommentDelete() { const path = conversationHolder.getAttribute('data-path'); const side = conversationHolder.getAttribute('data-side'); const idx = conversationHolder.getAttribute('data-idx'); - const lineType = conversationHolder.closest('tr').getAttribute('data-line-type'); - - if (lineType === 'same') { - document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible'); - } else { - document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible'); + const lineType = conversationHolder.closest('tr')?.getAttribute('data-line-type'); + + // the conversation holder could appear either on the "Conversation" page, or the "Files Changed" page + // on the Conversation page, there is no parent "tr", so no need to do anything for "add-code-comment" + if (lineType) { + if (lineType === 'same') { + document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible'); + } else { + document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible'); + } } - conversationHolder.remove(); } |