on xenial help sign in
Hide keyboard when Launcher or Drawer are dragged

The Launcher and Drawer do not respect the on-screen keyboard rectangle, so about half of them are hidden when the Drawer's search field is focused. To fix this, unfocus the Drawer's search field when either of them move. This does not remove focus when the user scrolls with the mouse wheel, only when they click and drag or touch and drag. Fixes https://github.com/ubports/ubuntu-touch/issues/1238 Fixes https://github.com/ubports/ubuntu-touch/issues/1245

commit329a3859395ae1d59b94879d01da4dde2333e751 authorDalton Durst <dalton@ubports.com> dateMon 14 Oct 2019, 19:58 (7 years ago) parent2c2664a
4 files changed+47
qml/Launcher/Drawer.qml+9 qml/Launcher/DrawerGridView.qml+1 qml/Launcher/Launcher.qml+4 tests/qmltests/Launcher/tst_Drawer.qml+33
qml/Launcher/Drawer.qml+9
@@ -115,6 +115,10 @@ FocusScope {
115115 searchField.focus = true;
116116 }
117117
118+ function unFocusInput() {
119+ searchField.focus = false;
120+ }
121+
118122 Keys.onPressed: {
119123 if (event.text.trim() !== "") {
120124 focusInput();
@@ -279,6 +283,11 @@ FocusScope {
279283 delegateWidth: root.delegateWidth
280284 delegateHeight: units.gu(11)
281285 delegate: drawerDelegateComponent
286+ onDraggingVerticallyChanged: {
287+ if (draggingVertically) {
288+ unFocusInput();
289+ }
290+ }
282291 }
283292 }
284293
qml/Launcher/DrawerGridView.qml+1
@@ -26,6 +26,7 @@ FocusScope {
2626 property alias model: gridView.model
2727 property alias interactive: gridView.interactive
2828 property alias currentIndex: gridView.currentIndex
29+ property alias draggingVertically: gridView.draggingVertically
2930
3031 property alias header: gridView.header
3132 property alias topMargin: gridView.topMargin
qml/Launcher/Launcher.qml+4
@@ -439,6 +439,10 @@ FocusScope {
439439 root.focus = false;
440440 }
441441
442+ onDraggingChanged: {
443+ drawer.unFocusInput()
444+ }
445+
442446 Behavior on x {
443447 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate;
444448 NumberAnimation {
tests/qmltests/Launcher/tst_Drawer.qml+33
@@ -388,5 +388,38 @@ StyledItem {
388388 tryCompare(launcher, "state", "");
389389 tryCompare(drawer, "draggingHorizontally", false);
390390 }
391+
392+ function test_draggingAppListHidesKeyboard() {
393+ // Ensures that dragging on the list of apps unfocuses the search
394+ // field, hiding the keyboard
395+ // Fix for https://github.com/ubports/ubuntu-touch/issues/1238
396+ var drawer = dragDrawerIntoView();
397+ var appList = findChild(drawer, "drawerAppList");
398+ var searchField = drawer.searchTextField;
399+
400+ searchField.focus = true;
401+
402+ var startX = drawer.width / 2;
403+ var startY = drawer.height / 2;
404+ touchFlick(drawer, startX, startY, startX, startY+units.gu(1))
405+
406+ tryCompare(searchField, "focus", false);
407+ }
408+
409+ function test_draggingLauncherHidesKeyboard() {
410+ // Ensures that dragging on the Launcher unfocuses the search
411+ // field, hiding the keyboard
412+ // Fix for https://github.com/ubports/ubuntu-touch/issues/1245
413+ var drawer = dragDrawerIntoView();
414+ var searchField = drawer.searchTextField;
415+
416+ searchField.focus = true;
417+
418+ var startX = launcher.width / 2;
419+ var startY = launcher.height / 2;
420+ touchFlick(drawer, startX, startY, startX, startY+units.gu(1))
421+
422+ tryCompare(searchField, "focus", false);
423+ }
391424 }
392425}