Skip to content

Commit 476e6b0

Browse files
authored
feat(superdoc): center comment and document anchor on sidebar click (#2466)
* feat(superdoc): center comment and document anchor on sidebar click Target viewport center (38% from top) instead of the comment's current screen position when clicking a sidebar comment card. * refactor(superdoc): extract magic number into named constant Extract 0.38 viewport ratio into COMMENT_FOCUS_VIEWPORT_RATIO for readability and easier future adjustment.
1 parent c54ad66 commit 476e6b0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/superdoc/src/components/CommentsLayer/CommentDialog.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ const hasTextContent = computed(() => {
278278
279279
const setFocus = () => {
280280
const editor = proxy.$superdoc.activeEditor;
281-
const targetClientY = commentDialogElement.value?.getBoundingClientRect?.()?.top;
281+
const COMMENT_FOCUS_VIEWPORT_RATIO = 0.38;
282+
const targetClientY = Math.round(window.innerHeight * COMMENT_FOCUS_VIEWPORT_RATIO);
282283
const willChangeActiveThread = !props.comment.resolvedTime && activeComment.value !== props.comment.commentId;
283284
if (willChangeActiveThread) {
284285
requestInstantSidebarAlignment(targetClientY);

0 commit comments

Comments
 (0)