fix: reset view state when switching sort modes#687
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideResets the app list view to the top immediately and without animation whenever the sort mode is switched between grid and list, by invoking a new view reset hook on the active loader item after updating its source component. Sequence diagram for resetting view state on sort mode changesequenceDiagram
actor User
participant AppList
participant Loader
participant AppListView
User->>AppList: changeSortMode(newMode)
AppList->>Loader: set sourceComponent(gridView or listView)
Loader-->>AppList: sourceComponent updated
AppList->>Loader: access item
alt loader.item exists
AppList->>AppListView: resetViewState()
AppListView->>AppListView: setScrollPosition(0, noAnimation)
end
AppListView-->>User: top of app list visible immediately
Class diagram for AppList and view reset hook on sort mode changeclassDiagram
class AppList {
+Loader loader
+changeSortMode(newMode)
}
class Loader {
+AppListView item
+setSourceComponent(component)
}
class AppListView {
<<interface>>
+resetViewState()
}
class GridView {
+resetViewState()
}
class ListView {
+resetViewState()
}
AppList --> Loader : uses
Loader --> AppListView : holds item
AppListView <|.. GridView : implements
AppListView <|.. ListView : implements
AppList ..> AppListView : calls resetViewState() after sort mode change
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider guarding the
resetViewState()call (e.g., checking it exists or documenting it as part of the required interface) so that changingsourceComponentto something that doesn’t implement this method doesn’t cause runtime errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding the `resetViewState()` call (e.g., checking it exists or documenting it as part of the required interface) so that changing `sourceComponent` to something that doesn’t implement this method doesn’t cause runtime errors.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
BLumia
approved these changes
Dec 30, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, robertkill 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 |
18202781743
reviewed
Dec 30, 2025
1. Added logic to reset view state to top when switching between grid and list view modes 2. The reset happens immediately without animation to provide instant feedback 3. This ensures users always see the top of the app list after changing sort modes 4. Prevents confusion when switching modes leaves users at a random scroll position Influence: 1. Test switching between grid and list view modes 2. Verify view always resets to top position after mode switch 3. Check that reset happens instantly without animation 4. Ensure app list navigation remains consistent across mode changes fix: 切换排序模式时重置视图状态 1. 添加逻辑在网格和列表视图模式切换时重置视图到顶部 2. 重置立即发生且无动画,提供即时反馈 3. 确保用户在更改排序模式后始终能看到应用列表顶部 4. 防止切换模式时用户停留在随机滚动位置造成的混淆 Influence: 1. 测试在网格和列表视图模式之间切换 2. 验证模式切换后视图始终重置到顶部位置 3. 检查重置是否立即发生且无动画 4. 确保应用列表导航在不同模式切换间保持一致 PMS: BUG-346111
deepin pr auto review我来帮你分析这段代码的改动:
a) 安全性改进:
if (loader.item && typeof loader.item.resetViewState === "function") {
loader.item.resetViewState()
}b) 代码质量改进:
function resetViewToTop() {
if (loader.item && typeof loader.item.resetViewState === "function") {
loader.item.resetViewState()
}
}c) 性能考虑:
d) 代码规范:
总体来说,这个改动解决了切换排序模式后视图位置的问题,实现简洁有效。只需要在安全性检查方面做一些加强即可。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Influence:
fix: 切换排序模式时重置视图状态
Influence:
PMS: BUG-346111
Summary by Sourcery
Bug Fixes: