From 08882c63df57fc9c05cadb0b14181768fc54fbd0 Mon Sep 17 00:00:00 2001 From: Domagoj Kriskovic Date: Wed, 5 Mar 2025 12:35:05 +0100 Subject: [PATCH] Adjust scroll behavior in review panel to account for wrapped lines (#24029) GitOrigin-RevId: 748f7ffcdd2d0c83132b43de99b10f598227f6b0 --- .../components/review-panel-entry.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx b/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx index c8495e7779..03fde3fd67 100644 --- a/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx +++ b/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx @@ -94,9 +94,20 @@ export const ReviewPanelEntry: FC<{ // scroll to line (centered) const blockInfo = view.lineBlockAt(position) + const coordsAtPos = view.coordsAtPos(position) + const coordsAtLineStart = view.coordsAtPos(blockInfo.from) + let wrappedLineOffset = 0 + if (coordsAtPos !== null && coordsAtLineStart !== null) { + wrappedLineOffset = coordsAtPos.top - coordsAtLineStart.top + } + const editorHeight = view.scrollDOM.getBoundingClientRect().height view.scrollDOM.scrollTo({ - top: blockInfo.top - editorHeight / 2 + blockInfo.height, + top: + blockInfo.top - + editorHeight / 2 + + view.defaultLineHeight + + wrappedLineOffset, behavior: 'smooth', }) })