Skip to content

fix: improve resetViewState to avoid animation glitches#685

Merged
robertkill merged 1 commit into
linuxdeepin:masterfrom
robertkill:master
Dec 30, 2025
Merged

fix: improve resetViewState to avoid animation glitches#685
robertkill merged 1 commit into
linuxdeepin:masterfrom
robertkill:master

Conversation

@robertkill

@robertkill robertkill commented Dec 30, 2025

Copy link
Copy Markdown
Contributor
  1. Modified resetViewState function in AppListView.qml and FreeSortListView.qml
  2. Temporarily disable highlightFollowsCurrentItem property during reset
  3. Set currentIndex to 0 and contentY to 0 to ensure proper reset
  4. Restore original highlightFollowsCurrentItem state after reset
  5. This prevents animation glitches when resetting view state

Log: Fixed animation issues when resetting application list view

Influence:

  1. Test resetting application list view after search or category filtering
  2. Verify that no animation glitches occur during view reset
  3. Check that current selection is properly reset to first item
  4. Test with different highlight modes and settings
  5. Verify that view position is correctly reset to top

fix: 改进 resetViewState 函数以避免动画闪烁问题

  1. 修改 AppListView.qml 和 FreeSortListView.qml 中的 resetViewState 函数
  2. 在重置过程中临时禁用 highlightFollowsCurrentItem 属性
  3. 将 currentIndex 设置为 0,contentY 设置为 0 以确保正确重置
  4. 重置后恢复原始的 highlightFollowsCurrentItem 状态
  5. 这可以防止重置视图状态时出现动画闪烁问题

Log: 修复重置应用列表视图时的动画问题

Influence:

  1. 测试在搜索或分类筛选后重置应用列表视图
  2. 验证在视图重置过程中不会出现动画闪烁
  3. 检查当前选择是否正确重置到第一个项目
  4. 使用不同的高亮模式和设置进行测试
  5. 验证视图位置是否正确重置到顶部

PMS: BUG-346111

Summary by Sourcery

Bug Fixes:

  • Prevent animation glitches when resetting the app list view and free-sort list view state by adjusting how the view is reset.

1. Modified resetViewState function in AppListView.qml and
FreeSortListView.qml
2. Temporarily disable highlightFollowsCurrentItem property during reset
3. Set currentIndex to 0 and contentY to 0 to ensure proper reset
4. Restore original highlightFollowsCurrentItem state after reset
5. This prevents animation glitches when resetting view state

Log: Fixed animation issues when resetting application list view

Influence:
1. Test resetting application list view after search or category
filtering
2. Verify that no animation glitches occur during view reset
3. Check that current selection is properly reset to first item
4. Test with different highlight modes and settings
5. Verify that view position is correctly reset to top

fix: 改进 resetViewState 函数以避免动画闪烁问题

1. 修改 AppListView.qml 和 FreeSortListView.qml 中的 resetViewState 函数
2. 在重置过程中临时禁用 highlightFollowsCurrentItem 属性
3. 将 currentIndex 设置为 0,contentY 设置为 0 以确保正确重置
4. 重置后恢复原始的 highlightFollowsCurrentItem 状态
5. 这可以防止重置视图状态时出现动画闪烁问题

Log: 修复重置应用列表视图时的动画问题

Influence:
1. 测试在搜索或分类筛选后重置应用列表视图
2. 验证在视图重置过程中不会出现动画闪烁
3. 检查当前选择是否正确重置到第一个项目
4. 使用不同的高亮模式和设置进行测试
5. 验证视图位置是否正确重置到顶部

PMS: BUG-346111
@sourcery-ai

sourcery-ai Bot commented Dec 30, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refines the resetViewState behavior for the app list views by temporarily disabling highlight tracking and explicitly resetting index and scroll position to avoid highlight/animation glitches when resetting the view.

Sequence diagram for improved resetViewState behavior in app list views

sequenceDiagram
    actor User
    participant AppListView
    participant ListView as listView

    User->>AppListView: trigger resetViewState
    AppListView->>ListView: read highlightFollowsCurrentItem
    AppListView->>ListView: set highlightFollowsCurrentItem = false
    AppListView->>ListView: set currentIndex = 0
    AppListView->>ListView: set contentY = 0
    AppListView->>ListView: restore highlightFollowsCurrentItem
    AppListView->>AppListView: close alphabetCategoryPopup if needed
    AppListView->>AppListView: close categoryMenu if needed
    AppListView-->>User: view reset without animation glitches
Loading

File-Level Changes

Change Details Files
Refine AppListView resetViewState to explicitly reset selection and scroll without highlight animations.
  • Replace positionViewAtBeginning() with manual reset of currentIndex to 0 and contentY to 0
  • Capture current highlightFollowsCurrentItem state, set it to false during the reset, and restore it afterward
  • Keep existing logic that closes alphabetCategoryPopup and categoryMenu when launcher is not visible
qml/windowed/AppListView.qml
Refine FreeSortListView resetViewState to use the same explicit reset logic and temporary highlight disabling.
  • Replace positionViewAtBeginning() with manual reset of listView.currentIndex to 0 and listView.contentY to 0
  • Temporarily set listView.highlightFollowsCurrentItem to false during the reset and restore its original value afterward
qml/windowed/FreeSortListView.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这段代码进行审查:

  1. 代码逻辑分析:
    这段代码修改了两个QML文件中的resetViewState()函数实现。主要改动是:
  • 临时禁用了highlightFollowsCurrentItem属性
  • 直接设置currentIndex和contentY来重置视图
  • 最后恢复highlightFollowsCurrentItem的原始值
  1. 代码质量评价:
    优点:
  • 添加了清晰的注释说明修改目的
  • 保存并恢复了原始的highlightFollowsCurrentItem状态
  • 使用了有意义的变量名(wasFollowing)

改进建议:

  • 可以将这段重置逻辑抽取为一个单独的函数,避免重复代码
  • 建议添加错误处理,确保即使发生异常也能恢复原始状态
  1. 性能考虑:
  • 直接设置currentIndex和contentY比调用positionViewAtBeginning()更直接,性能应该更好
  • 避免了不必要的动画效果,有助于提升性能
  1. 安全性分析:
  • 代码本身没有明显的安全风险
  • 但建议添加空值检查,确保listView对象存在

改进建议代码:

function resetViewStateSafely(listView) {
    if (!listView) {
        console.warn("ListView is null or undefined")
        return
    }
    
    try {
        const wasFollowing = listView.highlightFollowsCurrentItem
        listView.highlightFollowsCurrentItem = false
        listView.currentIndex = 0
        listView.contentY = 0
        listView.highlightFollowsCurrentItem = wasFollowing
    } catch (error) {
        console.error("Error while resetting view state:", error)
    }
}

// 在AppListView.qml中:
function resetViewState() {
    resetViewStateSafely(listView)
    if (!LauncherController.visible) {
        alphabetCategoryPopup.close()
        if (categoryMenu) categoryMenu.close()
    }
}

// 在FreeSortListView.qml中:
function resetViewState() {
    resetViewStateSafely(listView)
}

这样改进后的代码:

  1. 提高了代码复用性
  2. 增加了错误处理
  3. 添加了空值检查
  4. 保持了原有的功能
  5. 更容易维护和调试

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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:

  • The resetViewState logic is now duplicated between AppListView and FreeSortListView; consider extracting this into a shared helper or common function to avoid divergence if the reset behavior needs to change again.
  • Instead of manually setting currentIndex and contentY, you might call positionViewAtBeginning() while highlightFollowsCurrentItem is temporarily disabled, so you preserve any additional behavior encapsulated in positionViewAtBeginning.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The resetViewState logic is now duplicated between AppListView and FreeSortListView; consider extracting this into a shared helper or common function to avoid divergence if the reset behavior needs to change again.
- Instead of manually setting currentIndex and contentY, you might call positionViewAtBeginning() while highlightFollowsCurrentItem is temporarily disabled, so you preserve any additional behavior encapsulated in positionViewAtBeginning.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@robertkill robertkill merged commit ead060e into linuxdeepin:master Dec 30, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants