@@ -176,7 +176,6 @@ FocusScope {
176 superPressTimer.stop();
176 superPressTimer.stop();
177 superLongPressTimer.stop();
177 superLongPressTimer.stop();
178 root.focus = true;
178 root.focus = true;
179− drawer.focus = true;
180 if (focusInputField) {
179 if (focusInputField) {
181 drawer.focusInput();
180 drawer.focusInput();
@@ -350,19 +349,26 @@ FocusScope {
350 bottom: parent.bottom
349 bottom: parent.bottom
351 right: parent.left
350 right: parent.left
352 onRightMarginChanged: {
351 onRightMarginChanged: {
353− // Remove (and put back) the focus for the searchfield in
352+ if (fullyOpen && hadFocus) {
354− // order to hide the copy/paste popover when we move the drawer
353+ // See drawer.onDraggingHorizontallyChanged below
355− var hadFocus = drawer.searchTextField.focus;
356− var oldSelectionStart = drawer.searchTextField.selectionStart;
357− var oldSelectionEnd = drawer.searchTextField.selectionEnd;
358− drawer.searchTextField.focus = false;
359− drawer.searchTextField.focus = hadFocus;
354+ drawer.searchTextField.focus = hadFocus;
360− drawer.searchTextField.select(oldSelectionStart, oldSelectionEnd);
355+ drawer.searchTextField.select(oldSelectionStart, oldSelectionEnd);
357+ } else if (fullyClosed) {
358+ drawer.searchTextField.clear();
363 width: Math.min(root.width, units.gu(81))
363 width: Math.min(root.width, units.gu(81))
364 panelWidth: panel.width
364 panelWidth: panel.width
365 visible: x > -width
365 visible: x > -width
366+ property var fullyOpen: x === 0
367+ property var fullyClosed: x === -width
369+ property var hadFocus: false
370+ property var oldSelectionStart: null
371+ property var oldSelectionEnd: null
367 Behavior on anchors.rightMargin {
373 Behavior on anchors.rightMargin {
368 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate && !drawer.draggingHorizontally
374 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate && !drawer.draggingHorizontally
@@ -378,6 +384,12 @@ FocusScope {
378 root.focus = false;
384 root.focus = false;
387+ function resetOldFocus() {
389+ oldSelectionStart = null;
390+ oldSelectionEnd = null;
381 Keys.onEscapePressed: {
393 Keys.onEscapePressed: {
382 root.hide()
394 root.hide()
@@ -386,7 +398,15 @@ FocusScope {
386 anchors.rightMargin = Math.max(-drawer.width, anchors.rightMargin + dragDistance);
398 anchors.rightMargin = Math.max(-drawer.width, anchors.rightMargin + dragDistance);
388 onDraggingHorizontallyChanged: {
400 onDraggingHorizontallyChanged: {
389− if (!draggingHorizontally) {
401+ if (draggingHorizontally) {
402+ // Remove (and put back using anchors.onRightMarginChanged) the
403+ // focus for the searchfield in order to hide the copy/paste
404+ // popover when we move the drawer
405+ hadFocus = drawer.searchTextField.focus;
406+ oldSelectionStart = drawer.searchTextField.selectionStart;
407+ oldSelectionEnd = drawer.searchTextField.selectionEnd;
408+ drawer.searchTextField.focus = false;
390 if (drawer.x < -units.gu(10)) {
410 if (drawer.x < -units.gu(10)) {
391 root.hide();
411 root.hide();
@@ -572,6 +592,7 @@ FocusScope {
572 PropertyChanges {
592 PropertyChanges {
573 target: drawer
593 target: drawer
574 anchors.rightMargin: 0
594 anchors.rightMargin: 0
@@ -591,6 +612,7 @@ FocusScope {
591 PropertyChanges {
612 PropertyChanges {
592 target: drawer
613 target: drawer
593 anchors.rightMargin: -drawer.width + root.x // so we never go past panelWidth, even when teased by tutorial
614 anchors.rightMargin: -drawer.width + root.x // so we never go past panelWidth, even when teased by tutorial