-
Notifications
You must be signed in to change notification settings - Fork 33
fix: reset view state when switching sort modes #687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
[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 |
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) 代码规范:
总体来说,这个改动解决了切换排序模式后视图位置的问题,实现简洁有效。只需要在安全性检查方面做一些加强即可。 |
Influence:
fix: 切换排序模式时重置视图状态
Influence:
PMS: BUG-346111
Summary by Sourcery
Bug Fixes: