diff --git a/qml/Launcher/Drawer.qml b/qml/Launcher/Drawer.qml index c044b1f45d..5b7cb21eb0 100644 --- a/qml/Launcher/Drawer.qml +++ b/qml/Launcher/Drawer.qml @@ -115,6 +115,10 @@ FocusScope { searchField.focus = true; } + function unFocusInput() { + searchField.focus = false; + } + Keys.onPressed: { if (event.text.trim() !== "") { focusInput(); @@ -279,6 +283,11 @@ FocusScope { delegateWidth: root.delegateWidth delegateHeight: units.gu(11) delegate: drawerDelegateComponent + onDraggingVerticallyChanged: { + if (draggingVertically) { + unFocusInput(); + } + } } } diff --git a/qml/Launcher/DrawerGridView.qml b/qml/Launcher/DrawerGridView.qml index 5d9c80200a..85ece625d0 100644 --- a/qml/Launcher/DrawerGridView.qml +++ b/qml/Launcher/DrawerGridView.qml @@ -26,6 +26,7 @@ FocusScope { property alias model: gridView.model property alias interactive: gridView.interactive property alias currentIndex: gridView.currentIndex + property alias draggingVertically: gridView.draggingVertically property alias header: gridView.header property alias topMargin: gridView.topMargin diff --git a/qml/Launcher/Launcher.qml b/qml/Launcher/Launcher.qml index 464d49eec7..ca5019e072 100644 --- a/qml/Launcher/Launcher.qml +++ b/qml/Launcher/Launcher.qml @@ -439,6 +439,10 @@ FocusScope { root.focus = false; } + onDraggingChanged: { + drawer.unFocusInput() + } + Behavior on x { enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate; NumberAnimation { diff --git a/tests/qmltests/Launcher/tst_Drawer.qml b/tests/qmltests/Launcher/tst_Drawer.qml index 7db9473086..f73f068172 100644 --- a/tests/qmltests/Launcher/tst_Drawer.qml +++ b/tests/qmltests/Launcher/tst_Drawer.qml @@ -388,5 +388,38 @@ StyledItem { tryCompare(launcher, "state", ""); tryCompare(drawer, "draggingHorizontally", false); } + + function test_draggingAppListHidesKeyboard() { + // Ensures that dragging on the list of apps unfocuses the search + // field, hiding the keyboard + // Fix for https://github.com/ubports/ubuntu-touch/issues/1238 + var drawer = dragDrawerIntoView(); + var appList = findChild(drawer, "drawerAppList"); + var searchField = drawer.searchTextField; + + searchField.focus = true; + + var startX = drawer.width / 2; + var startY = drawer.height / 2; + touchFlick(drawer, startX, startY, startX, startY+units.gu(1)) + + tryCompare(searchField, "focus", false); + } + + function test_draggingLauncherHidesKeyboard() { + // Ensures that dragging on the Launcher unfocuses the search + // field, hiding the keyboard + // Fix for https://github.com/ubports/ubuntu-touch/issues/1245 + var drawer = dragDrawerIntoView(); + var searchField = drawer.searchTextField; + + searchField.focus = true; + + var startX = launcher.width / 2; + var startY = launcher.height / 2; + touchFlick(drawer, startX, startY, startX, startY+units.gu(1)) + + tryCompare(searchField, "focus", false); + } } }