diff --git a/panels/notification/center/NotifyView.qml b/panels/notification/center/NotifyView.qml index 8e11920c1..269870741 100644 --- a/panels/notification/center/NotifyView.qml +++ b/panels/notification/center/NotifyView.qml @@ -61,12 +61,41 @@ Control { activeFocusOnTab: false ScrollBar.vertical: ScrollBar { } property int nextIndex: -1 + property int pendingFocusIndex: -1 // Index to focus after expand operation property bool panelShown: false // Forward signals from delegate to root for Tab cycling function gotoHeaderFirst() { root.gotoHeaderFirst() } function gotoHeaderLast() { root.gotoHeaderLast() } + // Request focus on item after expand with retry + function requestFocusOnExpand(idx) { + pendingFocusIndex = idx + currentIndex = idx + positionViewAtIndex(idx, ListView.Contain) + expandFocusTimer.retries = 15 + expandFocusTimer.start() + } + + Timer { + id: expandFocusTimer + property int retries: 15 + interval: 50 + repeat: true + onTriggered: { + let item = view.itemAtIndex(view.pendingFocusIndex) + if (item && item.enabled) { + item.forceActiveFocus() + view.pendingFocusIndex = -1 + stop() + } else if (retries <= 0) { + view.pendingFocusIndex = -1 + stop() + } + retries-- + } + } + onNextIndexChanged: { if (nextIndex >= 0 && count > 0) { currentIndex = nextIndex diff --git a/panels/notification/center/NotifyViewDelegate.qml b/panels/notification/center/NotifyViewDelegate.qml index 2d2573a71..000ce4bca 100644 --- a/panels/notification/center/NotifyViewDelegate.qml +++ b/panels/notification/center/NotifyViewDelegate.qml @@ -80,7 +80,9 @@ DelegateChooser { onCollapse: function () { console.log("collapse group", model.appName) + let collapseIndex = index notifyModel.collapseApp(index) + root.view.requestFocusOnExpand(collapseIndex) } onSetting: function (pos) { @@ -259,7 +261,7 @@ DelegateChooser { console.log("expand") let expandIndex = model.index notifyModel.expandApp(expandIndex) - root.view.nextIndex = expandIndex + 1 + root.view.requestFocusOnExpand(expandIndex + 1) } onSetting: function (pos) { let tmp = mapToItem(root.view, pos)