From 94a8edcb9d8e17a2b85af1b1f1054340d437d334 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Sat, 29 Jan 2022 17:41:40 +0800 Subject: [PATCH] applets/clipboard: Fix highlight after exiting edit mode 1. Don't change the current item when not saving it. 2. Use Qt.callLater as the item will be moved to the top after saving it, and we would like to hightlight the real first item. --- applets/clipboard/contents/ui/EditPage.qml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/applets/clipboard/contents/ui/EditPage.qml b/applets/clipboard/contents/ui/EditPage.qml index 76a7b7198..2573a250a 100644 --- a/applets/clipboard/contents/ui/EditPage.qml +++ b/applets/clipboard/contents/ui/EditPage.qml @@ -21,7 +21,6 @@ ColumnLayout { Keys.onPressed: { if (event.key === Qt.Key_Escape) { stack.pop() - done(); event.accepted = true; } } @@ -38,8 +37,8 @@ ColumnLayout { } function done() { - stack.initialItem.view.currentIndex = 0; - stack.initialItem.view.currentItem.forceActiveFocus(); + // The modified item will be pushed to the top, and we would like to highlight the real first item + Qt.callLater(() => {stack.initialItem.view.currentIndex = 0;}); } PlasmaComponents3.ScrollView { @@ -79,7 +78,7 @@ ColumnLayout { PlasmaComponents3.Button { text: i18nc("@action:button", "Cancel") icon.name: "dialog-cancel" - onClicked: { stack.pop(); done() } + onClicked: stack.pop() } } }