fix focus after attempting to onebox

This commit is contained in:
Neil Lalonde 2016-12-08 16:26:59 -05:00
parent fbd8e6ed4a
commit 03ec8f8089
1 changed files with 10 additions and 4 deletions

View File

@ -66,10 +66,12 @@ export default Ember.Component.extend({
this._updatePost(lookupCache(this.get('composer.title'))); this._updatePost(lookupCache(this.get('composer.title')));
}).finally(() => { }).finally(() => {
this.set('composer.loading', false); this.set('composer.loading', false);
Ember.run.schedule('afterRender', () => { this.$('input').putCursorAtEnd(); });
}); });
} else { } else {
this._updatePost(loadOnebox); this._updatePost(loadOnebox);
this.set('composer.loading', false); this.set('composer.loading', false);
Ember.run.schedule('afterRender', () => { this.$('input').putCursorAtEnd(); });
} }
} }
}, },
@ -85,16 +87,20 @@ export default Ember.Component.extend({
this.set('composer.reply', this.get('composer.title')); this.set('composer.reply', this.get('composer.title'));
if (header.length > 0 && header.text().length > 0) { if (header.length > 0 && header.text().length > 0) {
this.set('composer.title', header.text().trim()); this.changeTitle(header.text());
} else { } else {
const filename = (this.get('composer.featuredLink')||"").split("/").pop(); const filename = (this.get('composer.featuredLink')||"").split("/").pop();
if (filename && filename.length > 0) { this.changeTitle(filename);
this.set('composer.title', filename.trim());
}
} }
} }
}, },
changeTitle(val) {
if (val && val.length > 0) {
this.set('composer.title', val.trim());
}
},
@computed('composer.title') @computed('composer.title')
isAbsoluteUrl() { isAbsoluteUrl() {
return this.get('composer.titleLength') > 0 && /^(https?:)?\/\/[\w\.\-]+/i.test(this.get('composer.title')); return this.get('composer.titleLength') > 0 && /^(https?:)?\/\/[\w\.\-]+/i.test(this.get('composer.title'));