on xenial help sign in
Prevent Drawer focus from flapping during transitions

I coded myself into a bit of a corner with the Drawer. Since it was undesirable for the Maliit Copy/Paste dialog and text selection baubles to stay rooted in place while the Drawer's search box moved underneath them, we strategically saved and removed focus from the search bar. This approach is very sensitive to changes in focus that come from outside itself. The Launcher's States were one such area causing these unexpected changes. It appears that a State extending another state applies all PropertyChanges from every state it extends. This meant that with the "visible" state setting "focus: false" on the Drawer, then the "drawer" state setting "focus: true", both changes occurred in quick succession. To fix this rapid off-on cycle during transitions, change the "drawer" state so it applies the relevant changes from "visible" but does not actually extend "visible". We also need to disable "restoreEntryValues" on the PropertyChanges because a "focus: false" before entering a state does not necessarily mean that "focus: false" should be set when leaving the same state.

commit5f847820776e314b24d42cd73a376f2ac122f859 authorDalton Durst <dalton@ubports.com> dateMon 31 May 2021, 18:44 (5 years ago) parentc6628ec
1 file changed+15−4
qml/Launcher/Launcher.qml+15−4
qml/Launcher/Launcher.qml+15−4
@@ -1,5 +1,6 @@
11/*
22 * Copyright (C) 2013-2015 Canonical, Ltd.
3+ * Copyright (C) 2021 UBports Foundation
34 *
45 * This program is free software; you can redistribute it and/or modify
56 * it under the terms of the GNU General Public License as published by
@@ -566,10 +567,12 @@ FocusScope {
566567 name: "" // hidden state. Must be the default state ("") because "when:" falls back to this.
567568 PropertyChanges {
568569 target: panel
570+ restoreEntryValues: false
569571 x: -root.panelWidth
570572 }
571573 PropertyChanges {
572574 target: drawer
575+ restoreEntryValues: false
573576 anchors.rightMargin: 0
574577 focus: false
575578 }
@@ -578,32 +581,38 @@ FocusScope {
578581 name: "visible"
579582 PropertyChanges {
580583 target: panel
584+ restoreEntryValues: false
581585 x: -root.x // so we never go past panelWidth, even when teased by tutorial
582586 focus: true
583587 }
584588 PropertyChanges {
585589 target: drawer
590+ restoreEntryValues: false
586591 anchors.rightMargin: 0
587592 focus: false
588593 }
589594 },
590595 State {
591596 name: "drawer"
592− extend: "visible"
597+ PropertyChanges {
598+ target: panel
599+ restoreEntryValues: false
600+ x: -root.x // so we never go past panelWidth, even when teased by tutorial
601+ focus: false
602+ }
593603 PropertyChanges {
594604 target: drawer
605+ restoreEntryValues: false
595606 anchors.rightMargin: -drawer.width + root.x // so we never go past panelWidth, even when teased by tutorial
596607 focus: true
597608 }
598− PropertyChanges {
599− target: panel
600− }
601609 },
602610 State {
603611 name: "visibleTemporary"
604612 extend: "visible"
605613 PropertyChanges {
606614 target: root
615+ restoreEntryValues: false
607616 autohideEnabled: true
608617 }
609618 },
@@ -612,6 +621,7 @@ FocusScope {
612621 when: teaseTimer.running && teaseTimer.mode == "teasing"
613622 PropertyChanges {
614623 target: panel
624+ restoreEntryValues: false
615625 x: -root.panelWidth + units.gu(2)
616626 }
617627 },
@@ -620,6 +630,7 @@ FocusScope {
620630 when: teaseTimer.running && teaseTimer.mode == "hinting"
621631 PropertyChanges {
622632 target: panel
633+ restoreEntryValues: false
623634 x: 0
624635 }
625636 }