fix: use positionViewAtBeginning instead of set contentY#748
Conversation
It is not recommended to use contentX or contentY to position the view at a particular index. This is unreliable since removing items from the start of the list does not cause all other items to be repositioned, and because the actual start of the view can vary based on the size of the delegates. PMS: BUG-356795 Log:
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaces direct manipulation of ListView scroll position via contentY with the recommended positionViewAtBeginning() API when resetting the app list view to the start, ensuring robust behavior when items are added/removed or delegate sizes vary. Sequence diagram for resetting the app list view to the beginningsequenceDiagram
actor User
participant AppListView
participant ListView
participant LauncherController
User->>AppListView: triggerReset()
AppListView->>ListView: set currentIndex(0)
AppListView->>ListView: set highlightFollowsCurrentItem(false)
AppListView->>ListView: positionViewAtBeginning()
AppListView->>ListView: restore highlightFollowsCurrentItem(wasFollowing)
AppListView->>LauncherController: check visible
alt LauncherController not visible
AppListView->>AppListView: alphabetCategoryPopup.close()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码修改主要涉及 QML 中 1. 语法逻辑审查
2. 代码质量审查
3. 代码性能审查
4. 代码安全审查
改进建议虽然这次修改是正向的,但根据具体场景,可以考虑以下微调:
总结这次修改是推荐的。它将直接操作属性替换为语义化的 API 调用,增强了代码的可读性和对复杂布局(如带 Header 的列表)的兼容性。唯一需要注意的是确认是否需要保留"瞬间跳转"的视觉效果,如果需要,可能需要配合禁用动画的属性使用。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
It is not recommended to use contentX or contentY to position the view at a particular index. This is unreliable since removing items from the start of the list does not cause all other items to be repositioned, and because the actual start of the view can vary based on the size of the delegates.
PMS: BUG-356795
Summary by Sourcery
Bug Fixes: