From 43fef292394b573bbce2e4a36d27cbf0fd9a12b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Wed, 19 Aug 2026 19:21:05 +0200 Subject: [PATCH] Add horizontal scrolling to scrollIntoViewIfNeeded Closes #15025 --- sao/src/common.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sao/src/common.js b/sao/src/common.js index 20b5d40d0f..d960652fb2 100644 --- a/sao/src/common.js +++ b/sao/src/common.js @@ -112,16 +112,25 @@ let container_rect = container.getBoundingClientRect(); let top_ = rect.top - container_rect.top; let bottom = top_ + rect.height; + let left = rect.left - container_rect.left; + let right = left + rect.width; let target_top = container.scrollTop; + let target_left = container.scrollLeft; if (top_ < 0) { target_top += top_ - container.clientHeight / 2; } else if (bottom > container.clientHeight) { target_top += bottom - container.clientHeight / 2 } + if (left < 0) { + target_left += left - container.clientWidth / 2; + } else if (right > container.clientWidth) { + target_left += right - container.clientWidth / 2; + } container.scrollTo({ top: Math.max(0, target_top), + left: Math.max(0, target_left), }); } }