fix(SearchBar): use Popup.Window to allow popup beyond window boundary - #3462
18202781743 wants to merge 1 commit into
Conversation
Set popupType to Popup.Window so the search result popup renders as an independent platform window, fixing the issue where it was clipped by the main window boundary. - Add popupType: Popup.Window - Add PopupHandle.enableBlurWindow for consistent blur/rounded corners - Add closePolicy for proper close behavior in Window mode - Add positionWindow() using mapToGlobal/mapFromGlobal for correct positioning with DWindow titlebar offset - Remove scale animation, keep only opacity for Window mode compatibility Log: fix popup clipping issue Bug: https://github.com/linuxdeepin/dde-control-center
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743 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 |
Reviewer's GuideUpdates the SearchBar results popup to use an independently rendered window, allowing it to extend beyond the main window while retaining expected positioning, dismissal behavior, styling, and keyboard usability. Sequence diagram for positioning and dismissing the SearchBar popupsequenceDiagram
participant SearchBar
participant PopupWindow
participant Window
SearchBar->>PopupWindow: onOpened
PopupWindow->>PopupWindow: positionWindow()
PopupWindow->>SearchBar: searchEdit.mapToGlobal(0, 0)
PopupWindow->>Window: Window.window.mapFromGlobal(globalPos.x, globalPos.y)
PopupWindow-->>PopupWindow: set x and y below searchEdit
alt Escape pressed
SearchBar->>PopupWindow: close
else Press outside parent
SearchBar->>PopupWindow: close
end
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 found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/dde-control-center/plugin/SearchBar.qml" line_range="114-125" />
<code_context>
height: (view.count > 7 ? 7 : view.count) * 32 + 15
padding: 5
+
+ function positionWindow() {
+ var globalPos = searchEdit.mapToGlobal(0, 0)
+ var w = Window.window
+ if (w) {
+ var localPos = w.mapFromGlobal(globalPos.x, globalPos.y)
+ x = localPos.x
+ y = localPos.y + searchEdit.height
+ }
+ }
+
+ onOpened: {
+ positionWindow()
+ }
ListView {
</code_context>
<issue_to_address>
**issue (broader_impact):** The independent popup window is positioned only once in `onOpened`; when the main control-center window moves or the SearchBar is repositioned while the results popup remains open, the popup stays at its old screen coordinates instead of following `searchEdit`.
**Triggers:** When the user moves or reflows the main window while search results are open.
**Suggested fix:** Reposition the popup when the parent window or SearchBar position changes, or close and reopen it when the anchor moves.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| function positionWindow() { | ||
| var globalPos = searchEdit.mapToGlobal(0, 0) | ||
| var w = Window.window | ||
| if (w) { | ||
| var localPos = w.mapFromGlobal(globalPos.x, globalPos.y) | ||
| x = localPos.x | ||
| y = localPos.y + searchEdit.height | ||
| } | ||
| } | ||
|
|
||
| onOpened: { | ||
| positionWindow() |
There was a problem hiding this comment.
issue (broader_impact): The independent popup window is positioned only once in onOpened; when the main control-center window moves or the SearchBar is repositioned while the results popup remains open, the popup stays at its old screen coordinates instead of following searchEdit.
Triggers: When the user moves or reflows the main window while search results are open.
Suggested fix: Reposition the popup when the parent window or SearchBar position changes, or close and reopen it when the anchor moves.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: ['建议在 positionWindow() 函数前添加简要注释,说明该函数通过全局坐标映射定位 Popup 窗口位置,参考 datetime 插件实现'] 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 修复安全漏洞,加强输入验证 💡 改进建议代码示例// 暂无代码示例本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.1.106 |
|
TAG Bot New tag: 6.1.107 |
问题
控制中心搜索栏的 Popup 默认使用
Popup.Item类型,弹窗在父窗口场景内渲染,被主窗口边界裁剪,无法超出窗口显示。修复方案
将搜索结果 Popup 改为
popupType: Popup.Window独立平台窗口模式,使其可超出主窗口边界渲染。改动内容
import QtQuick.Window 2.15,提供Window.window附加属性用于全局坐标映射。popupType: Popup.Window— 独立平台窗口渲染,解决裁剪问题。PopupHandle.enableBlurWindow: true— 与 datetime 插件一致的模糊/圆角外观。closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent— Window 模式下点击外部和 Esc 可关闭。positionWindow()函数,通过searchEdit.mapToGlobal(0, 0)+Window.window.mapFromGlobal()映射坐标定位,在onOpened中调用。参考 datetime 插件SearchableListViewPopup.positionWindow()实现。enter/exit的scale动画,仅保留opacity过渡。参考
f4845fcc0(SearchableListViewPopup.qml、RegionsChooserWindow.qml)焦点说明
SearchBar 的
searchEdit位于主窗口中(不在 Popup 内部),Up/Down/Enter/Escape 键盘导航由searchEdit.Keys.onPressed处理。Popup.Window(Qt::Tool 类型)不会抢占主窗口键盘焦点,searchEdit保持焦点,现有键盘导航继续可用。Log: fix popup clipping issue
Bug: https://github.com/linuxdeepin/dde-control-center
Summary by Sourcery
Render SearchBar results in a separately positioned window so the popup can extend beyond the main window boundary.
Bug Fixes:
Enhancements: