mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-29 21:51:39 +01:00
focus composer when replying
This commit is contained in:
parent
c3177b06bf
commit
2c8e259339
@ -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…
x
Reference in New Issue
Block a user