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

Commit

Permalink
Bug 1120018 - [RTL][Messages] Fix composer text content direction iss…
Browse files Browse the repository at this point in the history
…ue, r=julienw
  • Loading branch information
steveck-chung authored and rvandermeulen committed Feb 10, 2015
1 parent 778f33c commit 705699a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/sms/js/subject_composer.js
Expand Up @@ -62,6 +62,17 @@
}
}

/** Without bug 1103011 fixed, subject's caret would not be set at correct
* position with dir attribute set to auto. So we need to specify the auto
* direction only when subject is not empty.
*/
function updateDirection(value) {
/* jshint validthis: true */
var priv = privateMembers.get(this);

priv.input.dir = value ? 'auto': '';
}

function updateValue(newValue) {
/* jshint validthis: true */
var priv = privateMembers.get(this);
Expand All @@ -75,6 +86,7 @@
if (priv.value !== newValue) {
priv.value = newValue;
priv.updatePlaceholder();
priv.updateDirection(newValue);

this.emit('change');
}
Expand Down Expand Up @@ -106,7 +118,8 @@

// methods
updateValue: updateValue.bind(this),
updatePlaceholder: updatePlaceholder.bind(this)
updatePlaceholder: updatePlaceholder.bind(this),
updateDirection: updateDirection.bind(this)
};
privateMembers.set(this, priv);

Expand Down
6 changes: 6 additions & 0 deletions apps/sms/style/composer.css
Expand Up @@ -107,6 +107,12 @@ form[role="search"] button[type="submit"] + p > textarea {

font-size: 1.7rem;
line-height: 2.1rem;

unicode-bidi: -moz-plaintext;
}

#messages-input.placeholder {
unicode-bidi: unset;
}

#messages-input:after {
Expand Down
15 changes: 15 additions & 0 deletions apps/sms/test/unit/subject_composer_test.js
Expand Up @@ -206,6 +206,21 @@ suite('SubjectComposer >', function() {
'Placeholder should be presented'
);
});

// Should be revisited again once bug 1103011 landed because we might
// not need this logic anymore.
test('correctly update dir attribute depends on input value', function() {
// Should be empty by default
assert.equal(input.dir, '');

// Should be auto when text input
subjectComposer.setValue('a');
assert.equal(input.dir, 'auto');

// Should reset to empty when text removed
subjectComposer.setValue('');
assert.equal(input.dir, '');
});
});

suite('Backspace key handling >', function() {
Expand Down

0 comments on commit 705699a

Please sign in to comment.