From ff47900283411e167d9476633795cb4f2d65b83e Mon Sep 17 00:00:00 2001 From: Mengci Cai Date: Fri, 20 Mar 2026 13:45:16 +0800 Subject: [PATCH] fix: prevent ListView overscroll in notification panel Added overscroll protection to the notification center ListView to prevent unwanted bounce-back behavior when scrolling beyond content boundaries. The fix includes three event handlers that monitor height, content height, and content position changes to ensure the scroll position stays within valid bounds. Implemented bounds checking in onHeightChanged, onContentHeightChanged, and onContentYChanged handlers to clamp the contentY position when it exceeds the content boundaries. This prevents the ListView from showing empty space when scrolled beyond the actual content area, which was causing visual glitches and inconsistent scrolling behavior. Influence: 1. Test scrolling to the top and bottom of notification list 2. Verify no empty space appears when reaching content boundaries 3. Check that normal scrolling behavior remains smooth 4. Test with various numbers of notifications (empty, few, many) 5. Verify scroll position is maintained during content updates PMS: BUG-284867 --- panels/notification/center/NotifyView.qml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/panels/notification/center/NotifyView.qml b/panels/notification/center/NotifyView.qml index 63b7234c5..36673c752 100644 --- a/panels/notification/center/NotifyView.qml +++ b/panels/notification/center/NotifyView.qml @@ -69,6 +69,25 @@ Control { property int pendingFocusIndex: -1 // Index to focus after expand operation property bool panelShown: false + // ListView滚轮回弹行为是默认行为,需要手动修正 + onHeightChanged: { + if (contentHeight > height && contentY > contentHeight - height) { + contentY = Math.max(0, contentHeight - height) + } + } + onContentHeightChanged: { + if (contentHeight > height && contentY > contentHeight - height) { + contentY = Math.max(0, contentHeight - height) + } + } + onContentYChanged: { + if (contentY < -1) { + contentY = 0 + } else if (contentHeight > height && contentY > contentHeight - height + 1) { + contentY = contentHeight - height + } + } + // Forward signals from delegate to root for Tab cycling function gotoHeaderFirst() { root.gotoHeaderFirst() } function gotoHeaderLast() { root.gotoHeaderLast() }