Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21100 from steveck-chung/bug-1021513
Browse files Browse the repository at this point in the history
Bug 1021513 - [Messages] Recipients list container scroll up automatically when dragging down. r=azasypkin
  • Loading branch information
steveck-chung authored and rvandermeulen committed Jun 30, 2014
1 parent 880049c commit d631e9a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
6 changes: 2 additions & 4 deletions apps/sms/js/recipients.js
Expand Up @@ -660,7 +660,7 @@

// Once the transition has ended, the set focus to
// the last child element in the recipients list view
view.inner.parentNode.addEventListener('transitionend', function te() {
view.outer.addEventListener('transitionend', function te() {
var last = view.inner.lastElementChild;
var previous;

Expand All @@ -677,9 +677,7 @@
if (opts.refocus) {
opts.refocus.focus();
}
}

if (last !== null) {
} else if (state.visible === 'multiline' && last !== null) {
last.scrollIntoView(true);
}

Expand Down
39 changes: 23 additions & 16 deletions apps/sms/test/unit/recipients_test.js
Expand Up @@ -818,7 +818,7 @@ suite('Recipients', function() {
this.sinon.stub(Navigation, 'isCurrentPanel').returns(false);
Navigation.isCurrentPanel.withArgs('composer').returns(true);

outer = document.getElementById('messages-recipients-list-container');
outer = document.getElementById('messages-to-field');
inner = document.getElementById('messages-recipients-list');
target = document.createElement('input');
visible = Recipients.View.prototype.visible;
Expand All @@ -832,13 +832,13 @@ suite('Recipients', function() {

test('singleline ', function() {
// Assert the last state is multiline
assert.equal(visible.args[0][0], 'multiline');
sinon.assert.calledWith(visible, 'multiline');
visible.reset();

// Next, set back to singleline
recipients.visible('singleline');

assert.ok(visible.called);
assert.equal(visible.args[1][0], 'singleline');
sinon.assert.calledWith(visible, 'singleline');
});

test('singleline + refocus (with recipients) ', function() {
Expand All @@ -848,7 +848,8 @@ suite('Recipients', function() {
recipients.add(fixture);

// Assert the last state is multiline
assert.equal(visible.args[0][0], 'multiline');
sinon.assert.calledWith(visible, 'multiline');
visible.reset();

recipients.visible('singleline', {
refocus: target
Expand All @@ -861,21 +862,20 @@ suite('Recipients', function() {
var last = inner.lastElementChild;

assert.ok(target.focus.called);
assert.ok(visible.called);
assert.equal(visible.args[1][0], 'singleline');
assert.deepEqual(visible.args[1][1], {
sinon.assert.calledWith(visible, 'singleline', {
refocus: target
});

assert.ok(last.scrollIntoView.called);
sinon.assert.notCalled(last.scrollIntoView);
});

test('singleline + refocus (no recipients) ', function() {
// Clear the spy intel
target.focus.reset();

// Assert the last state is multiline
assert.equal(visible.args[0][0], 'multiline');
sinon.assert.calledWith(visible, 'multiline');
visible.reset();

recipients.visible('singleline', {
refocus: target
Expand All @@ -886,9 +886,7 @@ suite('Recipients', function() {
);

assert.ok(target.focus.called);
assert.ok(visible.called);
assert.equal(visible.args[1][0], 'singleline');
assert.deepEqual(visible.args[1][1], {
sinon.assert.calledWith(visible, 'singleline', {
refocus: target
});
});
Expand All @@ -901,13 +899,22 @@ suite('Recipients', function() {

test('multiline ', function() {
// Assert the last state is singleline
assert.equal(visible.args[0][0], 'singleline');
sinon.assert.calledWith(visible, 'singleline');
visible.reset();

recipients.add(fixture);

// Next, set back to multiline
recipients.visible('multiline');

assert.ok(visible.called);
assert.equal(visible.args[1][0], 'multiline');
outer.dispatchEvent(
new CustomEvent('transitionend')
);

var last = inner.lastElementChild;

sinon.assert.calledWith(visible, 'multiline');
sinon.assert.called(last.scrollIntoView);
});
});
});
Expand Down

0 comments on commit d631e9a

Please sign in to comment.