Commit fc033427 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Rework keyboard focus strategy

Keeping the focus in the search field doesn't work anymore. Instead, make
it possible for the focus to go back and forth properly.

BUG: 388835
parent 7ec48a5b
......@@ -53,19 +53,21 @@ Kirigami.GlobalDrawer {
Navigation.openHome()
}
function suggestSearchText(text) {
toploader.item.text = text
toploader.item.forceActiveFocus()
}
topContent: ConditionalLoader {
id: toploader
condition: drawer.wideScreen
Layout.fillWidth: true
componentFalse: Item {
Layout.minimumHeight: 1
Keys.forwardTo: [window.pageStack]
}
componentTrue: SearchField {
id: searchField
visible: window.leftPage && (window.leftPage.searchFor != null || window.leftPage.hasOwnProperty("search"))
Keys.forwardTo: [window.pageStack]
page: window.leftPage
......@@ -76,6 +78,7 @@ Kirigami.GlobalDrawer {
Navigation.openApplicationList( { search: currentSearchText })
} else {
curr.search = currentSearchText;
curr.forceActiveFocus()
}
}
}
......
......@@ -57,4 +57,11 @@ Kirigami.ScrollablePage
root.refreshing = true
}
}
readonly property var readableCharacters: /\w+/
Keys.onPressed: {
if(event.text.length > 0 && event.modifiers === Qt.NoModifier && event.text.match(readableCharacters)) {
window.globalDrawer.suggestSearchText(event.text)
}
}
}
......@@ -197,7 +197,6 @@ Kirigami.ApplicationWindow
globalDrawer: DiscoverDrawer {
wideScreen: window.wideScreen
focus: true
}
onCurrentTopLevelChanged: {
......
......@@ -40,8 +40,6 @@ TextField
}
onAccepted: currentSearchText = text
Component.onCompleted: forceActiveFocus()
hoverEnabled: true
ToolTip {
delay: Kirigami.Units.longDuration
......
......@@ -35,6 +35,7 @@ ApplicationsListPage {
listHeaderExtra: SearchField {
id: searchField
focus: true
Component.onCompleted: forceActiveFocus()
Connections {
ignoreUnknownSignals: true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment