Merge lp:~michael-sheldon/ubuntu-ui-toolkit/fix-1518352 into lp:ubuntu-ui-toolkit/staging

Proposed by Michael Sheldon
Status: Merged
Approved by: Cris Dywan
Approved revision: 1725
Merged at revision: 1769
Proposed branch: lp:~michael-sheldon/ubuntu-ui-toolkit/fix-1518352
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 133 lines (+88/-2)
4 files modified
src/Ubuntu/Components/1.2/InputHandler.qml (+5/-1)
src/Ubuntu/Components/1.3/InputHandler.qml (+5/-1)
tests/unit/tst_components/tst_inputhandler_v12.qml (+39/-0)
tests/unit/tst_components/tst_inputhandler_v13.qml (+39/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-ui-toolkit/fix-1518352
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+278158@code.launchpad.net

Commit message

Set the activeFocus on the input component when a text input area receives focus

Description of the change

Set the activeFocus on the input component when a text input area receives focus

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

This needs unit tests.

review: Needs Fixing
Revision history for this message
Cris Dywan (kalikiana) wrote :

That's looking very nice! Thanks! Let's hope J is fine with it then I have no reason to stop it now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/1.2/InputHandler.qml'
2--- src/Ubuntu/Components/1.2/InputHandler.qml 2015-06-29 17:48:58 +0000
3+++ src/Ubuntu/Components/1.2/InputHandler.qml 2015-12-15 14:49:28 +0000
4@@ -285,13 +285,17 @@
5 }
6 ]
7
8- // brings the state back to default when the component looses focuse
9+ // brings the state back to default when the component looses focus
10+ // and ensures input has active focus when component regains focus
11 Connections {
12 target: main
13 ignoreUnknownSignals: true
14 onFocusChanged: {
15 UbuntuApplication.inputMethod.commit()
16 state = (main.focus) ? "" : "inactive";
17+ if (main.focus) {
18+ input.forceActiveFocus()
19+ }
20 }
21 }
22
23
24=== modified file 'src/Ubuntu/Components/1.3/InputHandler.qml'
25--- src/Ubuntu/Components/1.3/InputHandler.qml 2015-08-11 17:15:59 +0000
26+++ src/Ubuntu/Components/1.3/InputHandler.qml 2015-12-15 14:49:28 +0000
27@@ -285,13 +285,17 @@
28 }
29 ]
30
31- // brings the state back to default when the component looses focuse
32+ // brings the state back to default when the component looses focus
33+ // and ensures input has active focus when component regains focus
34 Connections {
35 target: main
36 ignoreUnknownSignals: true
37 onFocusChanged: {
38 UbuntuApplication.inputMethod.commit()
39 state = (main.focus) ? "" : "inactive";
40+ if (main.focus) {
41+ input.forceActiveFocus()
42+ }
43 }
44 }
45
46
47=== added file 'tests/unit/tst_components/tst_inputhandler_v12.qml'
48--- tests/unit/tst_components/tst_inputhandler_v12.qml 1970-01-01 00:00:00 +0000
49+++ tests/unit/tst_components/tst_inputhandler_v12.qml 2015-12-15 14:49:28 +0000
50@@ -0,0 +1,39 @@
51+/*
52+ * Copyright 2013 Canonical Ltd.
53+ *
54+ * This program is free software; you can redistribute it and/or modify
55+ * it under the terms of the GNU Lesser General Public License as published by
56+ * the Free Software Foundation; version 3.
57+ *
58+ * This program is distributed in the hope that it will be useful,
59+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
60+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+ * GNU Lesser General Public License for more details.
62+ *
63+ * You should have received a copy of the GNU Lesser General Public License
64+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
65+ */
66+
67+import QtQuick 2.0
68+import QtTest 1.0
69+import Ubuntu.Test 1.0
70+import Ubuntu.Components 1.2
71+
72+UbuntuTestCase {
73+ name: "InputHandlerTest"
74+
75+ TextField {
76+ id: tf
77+ }
78+
79+ function test_internalFocus() {
80+ var handler = findChild(tf, "input_handler");
81+ tf.focus = false
82+ handler.input.focus = false
83+ compare(tf.focus, false, "Text field doesn't have focus");
84+ compare(handler.input.focus, false, "Input doesn't have focus");
85+ tf.focus = true
86+ compare(tf.focus, true, "Focus restored to text field");
87+ compare(handler.input.focus, true, "Focus automatically restored to input handler");
88+ }
89+}
90
91=== added file 'tests/unit/tst_components/tst_inputhandler_v13.qml'
92--- tests/unit/tst_components/tst_inputhandler_v13.qml 1970-01-01 00:00:00 +0000
93+++ tests/unit/tst_components/tst_inputhandler_v13.qml 2015-12-15 14:49:28 +0000
94@@ -0,0 +1,39 @@
95+/*
96+ * Copyright 2013 Canonical Ltd.
97+ *
98+ * This program is free software; you can redistribute it and/or modify
99+ * it under the terms of the GNU Lesser General Public License as published by
100+ * the Free Software Foundation; version 3.
101+ *
102+ * This program is distributed in the hope that it will be useful,
103+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
104+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
105+ * GNU Lesser General Public License for more details.
106+ *
107+ * You should have received a copy of the GNU Lesser General Public License
108+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
109+ */
110+
111+import QtQuick 2.0
112+import QtTest 1.0
113+import Ubuntu.Test 1.0
114+import Ubuntu.Components 1.3
115+
116+UbuntuTestCase {
117+ name: "InputHandlerTest"
118+
119+ TextField {
120+ id: tf
121+ }
122+
123+ function test_internalFocus() {
124+ var handler = findChild(tf, "input_handler");
125+ tf.focus = false
126+ handler.input.focus = false
127+ compare(tf.focus, false, "Text field doesn't have focus");
128+ compare(handler.input.focus, false, "Input doesn't have focus");
129+ tf.focus = true
130+ compare(tf.focus, true, "Focus restored to text field");
131+ compare(handler.input.focus, true, "Focus automatically restored to input handler");
132+ }
133+}

Subscribers

People subscribed via source and target branches