Skip to content

Commit

Permalink
Unhide resolved comment when hovering in APIView (#6302)
Browse files Browse the repository at this point in the history
* add comment and diagnostics hover popup feature

* unhide resolved comments when hovering
  • Loading branch information
yeojunh authored Jun 7, 2023
1 parent 2cad14f commit 89cab83
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/dotnet/APIView/APIViewWeb/Client/src/shared/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $(() => {
let CurrentUserSuggestionElements: HTMLElement[] = [];
let CurrentUserSuggestionIndex = -1;
let CurrentCommentToggle = false;

// simple github username match
const githubLoginTagMatch = /(\s|^)@([a-zA-Z\d-]+)/g;

Expand Down Expand Up @@ -68,12 +69,15 @@ $(() => {

$(document).on("mouseenter", SEL_COMMENT_ICON, e => {
let lineId = getElementId(e.target);
if (lineId) {
if (getSingleCommentDisplayStatus(lineId)) {
CurrentCommentToggle = true;
} else {
toggleSingleCommentAndDiagnostics(lineId);
}
if (!lineId) {
return;
}

if (getSingleCommentAndDiagnosticsDisplayStatus(lineId)) {
CurrentCommentToggle = true;
} else {
toggleSingleCommentAndDiagnostics(lineId);
toggleSingleResolvedComment(lineId);
}
e.preventDefault();
});
Expand All @@ -88,12 +92,15 @@ $(() => {

$(document).on("mouseleave", SEL_COMMENT_ICON, e => {
let lineId = getElementId(e.target);
if (lineId) {
if (CurrentCommentToggle) {
CurrentCommentToggle = false;
} else {
toggleSingleCommentAndDiagnostics(lineId);
}
if (!lineId) {
return;
}

if (CurrentCommentToggle) {
CurrentCommentToggle = false;
} else {
toggleSingleCommentAndDiagnostics(lineId);
toggleSingleResolvedComment(lineId);
}
e.preventDefault();
});
Expand Down Expand Up @@ -596,10 +603,17 @@ $(() => {
getDiagnosticsRow(id).toggleClass("d-none");
}

function getSingleCommentDisplayStatus(id: string) {
function getSingleCommentAndDiagnosticsDisplayStatus(id: string) {
return !(getCommentsRow(id).hasClass("d-none") || getDiagnosticsRow(id).hasClass("d-none"));
}

function toggleSingleResolvedComment(id: string) {
let commentHolder = $(getCommentsRow(id)).find(".comment-holder").first();
if (commentHolder.hasClass("comments-resolved")) {
toggleComments(id);
}
}

function getDisplayedCommentRows(commentRows: JQuery<HTMLElement>, clearCommentAnchors = false, returnFirst = false) {
var displayedCommentRows: JQuery<HTMLElement>[] = [];
commentRows.each(function (index) {
Expand Down

0 comments on commit 89cab83

Please sign in to comment.