Skip to content

Commit ba20326

Browse files
committed
Reference the closest comment-editor section in the case where a work item is opened from the links section of another work item
1 parent feb21c5 commit ba20326

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/azdo-pr-dashboard.user.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,10 @@
985985
}
986986

987987
async function annotateWorkItemWithFollowerList(commentEditor) {
988-
document.querySelectorAll('.work-item-followers-list').forEach(e => e.remove());
988+
const commentEditorContainer = commentEditor.closest('.new-comment-div');
989+
commentEditorContainer.querySelectorAll('.work-item-followers-list').forEach(e => e.remove());
989990

990-
const workItemId = getCurrentWorkItemId();
991+
const workItemId = getCurrentWorkItemId(commentEditor);
991992
const queryResponse = await fetch(`${azdoApiBaseUrl}_apis/notification/subscriptionquery?api-version=6.0`, {
992993
method: 'POST',
993994
headers: {
@@ -1017,9 +1018,10 @@
10171018
}
10181019
}
10191020

1020-
function getCurrentWorkItemId() {
1021+
function getCurrentWorkItemId(commentEditor) {
10211022
// Try getting the link from the work item header, in case this is opened in preview view
1022-
const header = document.querySelector('.work-item-form-header');
1023+
const workItemPage = commentEditor.closest('.work-item-form-page');
1024+
const header = workItemPage.querySelector('.work-item-form-header');
10231025
const links = header.querySelectorAll('a');
10241026
// Loop through the links and check if their target matches a link for a work item
10251027
const workItemLink = Array.from(links).find(link => link.href.includes('_workitems'));

0 commit comments

Comments
 (0)