message_list_tooltips: Create '$template' conditionally.

We only expect 'data-tooltip-template-id' to be present if 'tippy_content'
is not valid.Hence, only when 'tippy_content' is undefined, should we create
'$template'.
This commit is contained in:
Varun Singh 2024-03-23 00:25:57 +05:30 committed by Tim Abbott
parent 92ba149f5f
commit b0377d5d6d
1 changed files with 6 additions and 2 deletions

View File

@ -193,8 +193,12 @@ export function initialize() {
// Handle dynamic "starred messages" and "edit" widgets.
const $elem = $(instance.reference);
const tippy_content = $elem.attr("data-tippy-content");
const $template = $(`#${CSS.escape($elem.attr("data-tooltip-template-id"))}`);
instance.setContent(tippy_content ?? parse_html($template.html()));
if (tippy_content !== undefined) {
instance.setContent(tippy_content);
} else {
const $template = $(`#${CSS.escape($elem.attr("data-tooltip-template-id"))}`);
instance.setContent(parse_html($template.html()));
}
},
onHidden(instance) {
instance.destroy();