Skip to content

Revert "fix: set focus to search edit when launcher becomes visible"#732

Closed
Ivy233 wants to merge 1 commit intolinuxdeepin:masterfrom
Ivy233:revert-729-fix/search-edit-focus-on-show
Closed

Revert "fix: set focus to search edit when launcher becomes visible"#732
Ivy233 wants to merge 1 commit intolinuxdeepin:masterfrom
Ivy233:revert-729-fix/search-edit-focus-on-show

Conversation

@Ivy233
Copy link
Contributor

@Ivy233 Ivy233 commented Mar 12, 2026

Reverts #729

Summary by Sourcery

Bug Fixes:

  • Stop forcing focus to the search input when the launcher window or fullscreen view is shown, restoring previous focus behavior.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ivy233

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

@github-actions
Copy link

github-actions bot commented Mar 12, 2026

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reverts the previous behavior that automatically focused the search input when the launcher became visible, while keeping the cleanup logic that runs when the launcher is hidden.

Sequence diagram for launcher visibility change and search edit cleanup

sequenceDiagram
    actor User
    participant LauncherController
    participant WindowedFrame
    participant FullscreenFrame
    participant WindowedSearchEdit as Windowed_searchEdit
    participant FullscreenSearchEdit as Fullscreen_searchEdit

    User->>LauncherController: showLauncher()
    LauncherController-->>LauncherController: visible = true
    LauncherController-->>WindowedFrame: onVisibleChanged()
    LauncherController-->>FullscreenFrame: onVisibleChanged()
    Note over WindowedSearchEdit,FullscreenSearchEdit: After revert, no automatic focus when visible becomes true

    User->>LauncherController: hideLauncher()
    LauncherController-->>LauncherController: visible = false
    LauncherController-->>WindowedFrame: onVisibleChanged()
    WindowedFrame->>WindowedSearchEdit: text = ""
    WindowedFrame->>WindowedSearchEdit: clearFocus()

    LauncherController-->>FullscreenFrame: onVisibleChanged()
    FullscreenFrame->>FullscreenSearchEdit: text = ""
    FullscreenFrame->>FullscreenSearchEdit: clearFocus()
Loading

File-Level Changes

Change Details Files
Remove automatic focusing of search edit when launcher becomes visible, and limit logic in visibility handler to only run on hide.
  • In the windowed launcher frame, stop forcing focus to the bottom bar search edit on LauncherController becoming visible
  • In the windowed launcher frame, return early from onVisibleChanged when the launcher is visible so cleanup runs only on hide
  • In the fullscreen launcher frame, stop forcing focus to the search edit on LauncherController becoming visible
  • In the fullscreen launcher frame, return early from onVisibleChanged when the launcher is visible so cleanup runs only on hide
qml/windowed/WindowedFrame.qml
qml/FullscreenFrame.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

Copy link

@sourcery-ai sourcery-ai bot left a 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:

  • The onVisibleChanged handlers in WindowedFrame.qml and FullscreenFrame.qml now contain nearly identical visibility guards and cleanup logic; consider extracting this into a shared helper or utility to avoid future divergence between the two implementations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `onVisibleChanged` handlers in `WindowedFrame.qml` and `FullscreenFrame.qml` now contain nearly identical visibility guards and cleanup logic; consider extracting this into a shared helper or utility to avoid future divergence between the two implementations.

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

deepin pr auto review

这段代码主要对启动器(Launcher)在可见性变化时的处理逻辑进行了简化。以下是对这段 diff 的详细审查意见:

1. 代码逻辑审查

观察:
代码将原本处理 LauncherController.visibletrue 时的逻辑块:

if (LauncherController.visible) {
    searchEdit.forceActiveFocus() // 或 bottomBar.searchEdit.forceActiveFocus()
    return
}

简化为了:

if (LauncherController.visible) return

问题:
这是一个功能性回退(Regression)。原代码在启动器显示时,会显式地将焦点强制设置到搜索框(forceActiveFocus),这是为了确保用户打开启动器后可以直接输入内容进行搜索,提升用户体验。
修改后的代码删除了 forceActiveFocus() 调用,这意味着当启动器显示时,焦点可能停留在上一次失去焦点时的组件上,或者根本没有焦点,导致用户无法直接开始搜索,必须手动点击搜索框。

建议:
如果这是一个旨在修复焦点冲突(例如导致其他窗口无法正确获取焦点)的改动,请确认是否有其他地方接管了焦点设置逻辑。如果是为了简化代码而进行的重构,这是不可接受的,因为它破坏了核心交互逻辑。

2. 代码质量与风格

优点:

  • 简化了控制流,使用了提前返回(early return)模式,减少了嵌套层级,使得清理逻辑(// only do these clean-up steps...)与判断逻辑解耦,阅读起来更清晰。
  • 保留了清晰的注释,说明了后续代码仅在启动器隐藏时执行。

改进建议:
虽然简化了结构,但由于丢失了核心功能,代码质量在功能完整性上是下降的。

3. 代码性能

  • 影响极小:删除 forceActiveFocus() 调用可能会减少一次 UI 更新和焦点计算,但这属于微优化,且以牺牲用户体验为代价,得不偿失。

4. 代码安全

  • 无明显安全问题:此处的修改仅涉及 UI 交互逻辑,不涉及内存安全或数据泄露等安全问题。

总结与修改建议

这段代码修改虽然在语法上没有错误,且在结构上更加简洁,但破坏了原有的交互逻辑(自动聚焦搜索框)

建议方案:

如果目的是为了优化代码结构(减少嵌套),建议保留 forceActiveFocus 的调用,改写如下:

对于 FullscreenFrame.qml:

Connections {
    target: LauncherController
    function onVisibleChanged() {
        if (LauncherController.visible) {
            searchEdit.forceActiveFocus()
            return
        }

        // only do these clean-up steps on launcher get hide
        searchEdit.text = ""
        if (listviewPage.currentItem) {
            // ... 后续清理逻辑
        }
    }
}

对于 WindowedFrame.qml:

Connections {
    target: LauncherController
    function onVisibleChanged() {
        if (LauncherController.visible) {
            bottomBar.searchEdit.forceActiveFocus()
            return
        }

        // only do these clean-up steps on launcher get hide
        bottomBar.searchEdit.text = ""
        // ... 后续清理逻辑
    }
}

结论: 请回滚该改动,或者提供删除 forceActiveFocus 的充分理由(例如:该功能导致了严重的 Bug 且有替代方案)。目前的 diff 不应被合并。

@Ivy233 Ivy233 closed this Mar 12, 2026
@Ivy233 Ivy233 deleted the revert-729-fix/search-edit-focus-on-show branch March 12, 2026 09:06
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.

2 participants