tooltip: Add channel folder tooltip for truncated names in left sidebar.

There isn't a way to check the complete name for long truncated channel
folders name in the left sidebar.

This commit adds a tooltip for channel folder only when the folder names
are truncated in the left sidebar.

Fixes: zulip#35582.
This commit is contained in:
Pratik Chanda
2025-08-13 03:15:05 +05:30
committed by Tim Abbott
parent ef3a68961d
commit 406b1e5a44

View File

@@ -1,4 +1,5 @@
import $ from "jquery";
import assert from "minimalistic-assert";
import * as tippy from "tippy.js";
import * as drafts from "./drafts.ts";
@@ -223,4 +224,25 @@ export function initialize(): void {
].join(","),
...topic_visibility_policy_tooltip_props,
});
tippy.delegate("body", {
target: ".stream-list-section-container .left-sidebar-title",
delay: LONG_HOVER_DELAY,
appendTo: () => document.body,
onShow(instance) {
const folder_name_element = instance.reference;
assert(folder_name_element instanceof HTMLElement);
if (folder_name_element.offsetWidth < folder_name_element.scrollWidth) {
const folder_name = folder_name_element.textContent ?? "";
instance.setContent(folder_name);
return undefined;
}
return false;
},
onHidden(instance) {
instance.destroy();
},
});
}