forked from mystiq/hydrogen-web
focus composer when replying
This commit is contained in:
parent
c3177b06bf
commit
2c8e259339
2 changed files with 11 additions and 0 deletions
|
@ -32,6 +32,7 @@ export class ComposerViewModel extends ViewModel {
|
|||
this._replyVM = this.track(this._roomVM._createTile(entry));
|
||||
}
|
||||
this.emitChange("replyViewModel");
|
||||
this.emit("focus");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ export class MessageComposer extends TemplateView {
|
|||
super(viewModel);
|
||||
this._input = null;
|
||||
this._attachmentPopup = null;
|
||||
this._focusInput = null;
|
||||
}
|
||||
|
||||
render(t, vm) {
|
||||
|
@ -34,6 +35,8 @@ export class MessageComposer extends TemplateView {
|
|||
onKeydown: e => this._onKeyDown(e),
|
||||
onInput: () => vm.setInput(this._input.value),
|
||||
});
|
||||
this._focusInput = () => this._input.focus();
|
||||
this.value.on("focus", this._focusInput);
|
||||
const replyPreview = t.map(vm => vm.replyViewModel, (rvm, t) => {
|
||||
const View = rvm && viewClassForEntry(rvm);
|
||||
if (!View) { return null; }
|
||||
|
@ -65,6 +68,13 @@ export class MessageComposer extends TemplateView {
|
|||
return t.div({ className: "MessageComposer" }, [replyPreview, input]);
|
||||
}
|
||||
|
||||
unmount() {
|
||||
if (this._focusInput) {
|
||||
this.value.off("focus", this._focusInput);
|
||||
}
|
||||
super.unmount();
|
||||
}
|
||||
|
||||
_clearReplyingTo() {
|
||||
this.value.clearReplyingTo();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue