diff --git a/src/comments/ycomments.js b/src/comments/ycomments.js index 52dd109..1325428 100644 --- a/src/comments/ycomments.js +++ b/src/comments/ycomments.js @@ -338,8 +338,14 @@ export class YComments { } parentLineHeight(commentId) { - let elem = this.mainCodeMirror.dom.querySelector("#" + commentId)?.previousSibling; - if (elem) return elem.clientHeight; + let elem; + if (this.display().isShown(commentId)) { + elem = this.mainCodeMirror.dom.querySelector("#" + commentId)?.previousSibling; + if (elem) return elem.clientHeight + 5; + } else { + elem = this.mainCodeMirror.dom.querySelector("#" + commentId)?.parentElement; + if (elem) return elem.clientHeight; + } let parentLineNumber = this.positionManager.get(commentId); return [...this.mainCodeMirror.dom.querySelectorAll(`.cm-gutterElement`)].find((e) => e.textContent == parentLineNumber)?.clientHeight; diff --git a/src/components/Comment.jsx b/src/components/Comment.jsx index 832e71c..9214233 100644 --- a/src/components/Comment.jsx +++ b/src/components/Comment.jsx @@ -82,7 +82,7 @@ const YComment = ({ ycomments, commentId }) => { [commentId], ); - const parentHeight = ycomments.parentLineHeight(commentId) + 3.8; + const parentHeight = ycomments.parentLineHeight(commentId) - 1; useEffect(() => { if (!cmref.current) {