Avoid inserting li tags outside a list

This commit is contained in:
Danila Fedorin 2021-07-22 12:51:24 -07:00
parent 66f686210f
commit 013f187dc2
2 changed files with 6 additions and 4 deletions

View File

@ -41,7 +41,7 @@ export class MessageComposer extends TemplateView {
t.span('Replying'), t.span('Replying'),
t.span({onClick: () => this._clearReplyingTo()}, 'Close'), t.span({onClick: () => this._clearReplyingTo()}, 'Close'),
// TODO need proper view, not just assumed TextMessageView // TODO need proper view, not just assumed TextMessageView
t.view(new TextMessageView(vm.replyViewModel, true)) t.view(new TextMessageView(vm.replyViewModel, true, "div"))
]) ])
), ),
this._input, this._input,

View File

@ -24,20 +24,22 @@ import {Menu} from "../../../general/Menu.js";
import {ReactionsView} from "./ReactionsView.js"; import {ReactionsView} from "./ReactionsView.js";
export class BaseMessageView extends TemplateView { export class BaseMessageView extends TemplateView {
constructor(value, disabled = false) { constructor(value, disabled = false, tagName = "li") {
super(value); super(value);
this._menuPopup = null; this._menuPopup = null;
this._tagName = tagName;
// TODO An enum could be nice to make code // TODO An enum could be nice to make code
// easier to read at call sites. // easier to read at call sites.
this._disabled = disabled; this._disabled = disabled;
} }
render(t, vm) { render(t, vm) {
const li = t.li({className: { const li = t.el(this._tagName, {className: {
"Timeline_message": true, "Timeline_message": true,
own: vm.isOwn, own: vm.isOwn,
unsent: vm.isUnsent, unsent: vm.isUnsent,
unverified: vm.isUnverified, unverified: vm.isUnverified,
disabled: this._disabled,
continuation: vm => vm.isContinuation, continuation: vm => vm.isContinuation,
}}, [ }}, [
// dynamically added and removed nodes are handled below // dynamically added and removed nodes are handled below
@ -115,8 +117,8 @@ export class BaseMessageView extends TemplateView {
const options = []; const options = [];
if (vm.canReact && vm.shape !== "redacted") { if (vm.canReact && vm.shape !== "redacted") {
options.push(new QuickReactionsMenuOption(vm)); options.push(new QuickReactionsMenuOption(vm));
}
options.push(Menu.option(vm.i18n`Reply`, () => vm.startReply())); options.push(Menu.option(vm.i18n`Reply`, () => vm.startReply()));
}
if (vm.canAbortSending) { if (vm.canAbortSending) {
options.push(Menu.option(vm.i18n`Cancel`, () => vm.abortSending())); options.push(Menu.option(vm.i18n`Cancel`, () => vm.abortSending()));
} else if (vm.canRedact) { } else if (vm.canRedact) {