Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#18895 from azasypkin/bug-996900-keyboa…
Browse files Browse the repository at this point in the history
…rd-on-click

Bug 996900 - [Messaging] Bring up keyboard when user taps in the middle of the Messaging screen. r=julien
  • Loading branch information
BavarianTomcat committed May 12, 2014
2 parents e8a1eed + 66bea2b commit d5d8062
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
28 changes: 17 additions & 11 deletions apps/sms/js/thread_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1887,21 +1887,27 @@ var ThreadUI = global.ThreadUI = {
handleEvent: function thui_handleEvent(evt) {
switch (evt.type) {
case 'click':
if (!this.inEditMode) {
// if the click wasn't on an attachment check for other clicks
if (!thui_mmsAttachmentClick(evt.target)) {
this.handleMessageClick(evt);
LinkActionHandler.onClick(evt);
if (this.inEditMode) {
var input = evt.target.parentNode.querySelector('input');
if (input) {
this.chooseMessage(input);
this.checkInputs();
}
return;
}

var input = evt.target.parentNode.querySelector('input');
if (input) {
this.chooseMessage(input);
this.checkInputs();
// If we're in composer, let's focus on message editor on click.
if (window.location.hash === '#new') {
Compose.focus();
return;
}
break;

// if the click wasn't on an attachment check for other clicks
if (!thui_mmsAttachmentClick(evt.target)) {
this.handleMessageClick(evt);
LinkActionHandler.onClick(evt);
}
return;
case 'contextmenu':
evt.preventDefault();
evt.stopPropagation();
Expand Down Expand Up @@ -2170,7 +2176,7 @@ var ThreadUI = global.ThreadUI = {
'NonActiveSimCardToSendError',
{
confirmHandler: function() {
// Update messageDOM state to 'sending' while sim switching
// Update messageDOM state to 'sending' while sim switching
messageDOM.classList.remove('error');
messageDOM.classList.add('sending');

Expand Down
27 changes: 27 additions & 0 deletions apps/sms/test/unit/thread_ui_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5367,4 +5367,31 @@ suite('thread_ui.js >', function() {
assert.isTrue(Recipients.View.isFocusable);
});
});

suite('Compose mode tests', function() {
teardown(function() {
window.location.hash = '';
Compose.clear();
});

suite('message editor focus', function() {
setup(function() {
this.sinon.spy(Compose, 'focus');
});

test('focus on container click if in Composer', function() {
window.location.hash = '#new';
container.click();

sinon.assert.called(Compose.focus);
});

test('do not focus on container click if not in Composer', function() {
window.location.hash = '#thread=1';

container.click();
sinon.assert.notCalled(Compose.focus);
});
});
});
});

0 comments on commit d5d8062

Please sign in to comment.