Merge lp:~osomon/ubuntu-ui-toolkit/child-activeFocusOnPress into lp:ubuntu-ui-toolkit/staging

Proposed by Olivier Tilloy
Status: Merged
Approved by: Cris Dywan
Approved revision: 1821
Merged at revision: 1821
Proposed branch: lp:~osomon/ubuntu-ui-toolkit/child-activeFocusOnPress
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 112 lines (+50/-10)
2 files modified
src/Ubuntu/Components/1.3/TextField.qml (+15/-9)
tests/unit_x11/tst_components/tst_focus.qml (+35/-1)
To merge this branch: bzr merge lp:~osomon/ubuntu-ui-toolkit/child-activeFocusOnPress
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+283910@code.launchpad.net

Commit message

Do not try to assign to non-existent property "activeFocusOnPress".

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Good find.

Please add a unit test for it, probably in tests/unit_x11/tst_components/tst_focus.qml and it's good to go.

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

Very nice. Thanks a lot!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

False negative above:
error: device not found

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.ubuntu.com/ubuntu-sdk/job/ubuntu-ui-toolkit-autolanding/97/
Executed test runs:
    None: https://jenkins.ubuntu.com/ubuntu-sdk/job/generic-land-mp/97/console

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

Same false positive:
error: device not found

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) 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.3/TextField.qml'
2--- src/Ubuntu/Components/1.3/TextField.qml 2016-01-13 14:25:22 +0000
3+++ src/Ubuntu/Components/1.3/TextField.qml 2016-01-26 09:57:19 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2015 Canonical Ltd.
7+ * Copyright 2015-2016 Canonical Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11@@ -896,10 +896,13 @@
12 onChildrenChanged: {
13 // reparenting
14 for (var i = 0; i < children.length; i++) {
15- children[i].parent = leftPane;
16- children[i].anchors.verticalCenter = verticalCenter;
17- children[i].activeFocusOnPress = false;
18- children[i].activeFocusOnTab = false;
19+ var child = children[i];
20+ child.parent = leftPane;
21+ child.anchors.verticalCenter = verticalCenter;
22+ if (child.hasOwnProperty("activeFocusOnPress")) {
23+ child.activeFocusOnPress = false;
24+ }
25+ child.activeFocusOnTab = false;
26 }
27 }
28 }
29@@ -920,10 +923,13 @@
30 onChildrenChanged: {
31 // reparenting
32 for (var i = 0; i < children.length; i++) {
33- children[i].parent = rightPane;
34- children[i].anchors.verticalCenter = verticalCenter;
35- children[i].activeFocusOnPress = false;
36- children[i].activeFocusOnTab = false;
37+ var child = children[i];
38+ child.parent = rightPane;
39+ child.anchors.verticalCenter = verticalCenter;
40+ if (child.hasOwnProperty("activeFocusOnPress")) {
41+ child.activeFocusOnPress = false;
42+ }
43+ child.activeFocusOnTab = false;
44 }
45 }
46 }
47
48=== modified file 'tests/unit_x11/tst_components/tst_focus.qml'
49--- tests/unit_x11/tst_components/tst_focus.qml 2015-12-16 07:42:17 +0000
50+++ tests/unit_x11/tst_components/tst_focus.qml 2016-01-26 09:57:19 +0000
51@@ -1,5 +1,5 @@
52 /*
53- * Copyright 2014 Canonical Ltd.
54+ * Copyright 2014-2016 Canonical Ltd.
55 *
56 * This program is free software; you can redistribute it and/or modify
57 * it under the terms of the GNU Lesser General Public License as published by
58@@ -51,6 +51,16 @@
59 TextField {
60 id: textField
61 text: "This is a text field with some text handling focus"
62+ primaryItem: MouseArea {
63+ id: textFieldPrimaryItem
64+ height: parent.height
65+ width: height
66+ }
67+ secondaryItem: TextField {
68+ id: textFieldSecondaryItem
69+ height: parent.height
70+ width: height
71+ }
72 }
73 TextArea {
74 id: textArea
75@@ -164,6 +174,12 @@
76 signalName: "onDestruction"
77 }
78
79+ SignalSpy {
80+ id: textFieldPrimaryItemClickedSpy
81+ target: textFieldPrimaryItem
82+ signalName: "onClicked"
83+ }
84+
85 function initTestCase() {
86 main.hasOSK = QuickUtils.inputMethodProvider !== ""
87 textField.forceActiveFocus();
88@@ -244,6 +260,24 @@
89 textField.text = text;
90 }
91
92+ function test_textfield_primary_and_secondary_items_keeps_focus() {
93+ textFieldPrimaryItemClickedSpy.clear();
94+ textField.forceActiveFocus();
95+ verify(textField.activeFocus);
96+ verify(!textFieldSecondaryItem.activeFocusOnPress);
97+
98+ var center = centerOf(textFieldPrimaryItem);
99+ mouseClick(textFieldPrimaryItem, center.x, center.y);
100+ compare(textFieldPrimaryItemClickedSpy.count, 1);
101+ verify(textField.activeFocus);
102+ verify(!textFieldPrimaryItem.activeFocus);
103+
104+ center = centerOf(textFieldSecondaryItem);
105+ mouseClick(textFieldSecondaryItem, center.x, center.y);
106+ verify(textField.activeFocus);
107+ verify(!textFieldSecondaryItem.activeFocus);
108+ }
109+
110 function test_combo_button_dropdown_focuses_component() {
111 textField.forceActiveFocus();
112 var dropdownButton = findChild(comboButton, "combobutton_dropdown");

Subscribers

People subscribed via source and target branches