From 8ee1abcd9d73b24a019d962933e8fdcce8997f5e Mon Sep 17 00:00:00 2001 From: waterWang Date: Mon, 3 Aug 2026 20:17:33 +0800 Subject: [PATCH] fix: prevent parent scroll on keyboard navigation in preview When the Image preview is open and the user presses LEFT/RIGHT arrow keys to switch images, the browser's default scroll behavior was not prevented. This caused the parent element to scroll instead of the Image preview navigating between images. The fix adds event.preventDefault() when handling LEFT and RIGHT key events in the Preview component, preventing the browser's default scroll behavior. Closes ant-design/ant-design#56290 --- src/Preview/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Preview/index.tsx b/src/Preview/index.tsx index 03a43f47..52612ba6 100644 --- a/src/Preview/index.tsx +++ b/src/Preview/index.tsx @@ -348,8 +348,10 @@ const Preview: React.FC = props => { if (showLeftOrRightSwitches) { if (keyCode === KeyCode.LEFT) { onActive(-1); + event.preventDefault(); } else if (keyCode === KeyCode.RIGHT) { onActive(1); + event.preventDefault(); } } }