Skip to content

fix: enable keyboard navigation in move note dialog#387

Open
JWWTSL wants to merge 1 commit into
linuxdeepin:develop/snipefrom
JWWTSL:develop/snipe
Open

fix: enable keyboard navigation in move note dialog#387
JWWTSL wants to merge 1 commit into
linuxdeepin:develop/snipefrom
JWWTSL:develop/snipe

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Jun 26, 2026

Copy link
Copy Markdown

log:The notebook ListView was skipped in the Tab chain and its selection only updated on mouse click, so Tab could not reach the list and arrow keys could not switch notebooks. Make currentIndex the single source of truth, enable activeFocusOnTab and key navigation, and sync it to dialog.index.

pms: bug-367597

log:The notebook ListView was skipped in the Tab chain and its selection
only updated on mouse click, so Tab could not reach the list and arrow
keys could not switch notebooks. Make currentIndex the single source of
truth, enable activeFocusOnTab and key navigation, and sync it to
dialog.index.

pms: bug-367597

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

Sorry @JWWTSL, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码完美修复了ListView与Dialog状态不同步的问题,实现了单一数据源管理
逻辑严密且完全符合QML最佳实践,无任何扣分项

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

在MoveDialog.qml中,将原有的直接赋值dialog.index修改为通过folderList.currentIndex进行中转。onVisibleChanged中重置为folderList.currentIndex = 0,MouseArea.onClicked中修改为folderList.currentIndex = index,并通过onCurrentIndexChanged信号将状态单向同步给dialog.index,彻底解决了键盘导航与鼠标点击状态脱节的逻辑错误。
建议:保持当前的单一数据源设计模式,避免后续开发中再次出现双向绑定的反模式。

  • 2.代码质量(良好)✓

新增了activeFocusOnTab和keyNavigationEnabled属性以完善键盘交互,并添加了详尽的中文注释说明修改意图,代码意图清晰,符合规范。
建议:无

  • 3.代码性能(无性能问题)✓

修改仅涉及简单的属性赋值和信号触发,没有引入额外的计算开销、循环或组件重载,对运行时性能无任何负面影响。
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅涉及前端UI组件的状态同步逻辑,不涉及任何网络请求、文件系统操作、用户输入的未过滤传递或动态代码执行,无安全风险。

  • 建议:无

■ 【改进建议代码示例】

--- a/src/gui/dialog/MoveDialog.qml
+++ b/src/gui/dialog/MoveDialog.qml
@@ -20,7 +20,7 @@ DialogWindow {
     height: 365
     width: 370
 
-    onVisibleChanged: if (visible) index = 0
+    onVisibleChanged: if (visible) folderList.currentIndex = 0
 
     header: DialogTitleBar {
         enableInWindowBlendBlur: true
@@ -41,10 +41,16 @@ DialogWindow {
         ListView {
             id: folderList
 
+            activeFocusOnTab: true
             clip: true
             height: 226
+            keyNavigationEnabled: true
             width: 348
 
+            // currentIndex 作为选中项的唯一来源,同步给 dialog.index,
+            // 使 Tab 可聚焦列表、上/下方向键可切换记事本
+            onCurrentIndexChanged: dialog.index = currentIndex
+
             ScrollBar.vertical: ScrollBar {
             }
             delegate: Rectangle {
@@ -124,7 +130,7 @@ DialogWindow {
                     hoverEnabled: true
 
                     onClicked: {
-                        dialog.index = index;
+                        folderList.currentIndex = index;
                     }
                     onEntered: {
                         folderItem.isHovered = true;

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