left_sidebar: Show tooltip only for truncated channel names.

This commit replaces the default HTML title attribute with a Tippy.js tooltip for channel names in the subscription block,
ensuring that tooltips are shown only when the name is truncated.

Fixes #31807.
This commit is contained in:
aditya.chaudhary1558@gmail.com 2024-10-03 05:25:23 +05:30
parent c032bd9e78
commit 537efad959
2 changed files with 18 additions and 1 deletions

View File

@ -92,7 +92,6 @@ async function navigation_tests(page: Page): Promise<void> {
await common.log_in(page);
await navigate_to_settings(page);
await navigate_using_left_sidebar(page, "Verona");
await page.click("#left-sidebar-navigation-list .home-link");

View File

@ -184,6 +184,24 @@ export function initialize(): void {
},
});
tippy.delegate("body", {
target: ".subscription_block",
trigger: "mouseenter",
delay: LONG_HOVER_DELAY,
placement: "right",
appendTo: () => document.body,
onShow(instance) {
const stream_name = instance.reference.querySelector(".stream-name");
assert(stream_name instanceof HTMLElement);
if (stream_name.offsetWidth >= stream_name.scrollWidth) {
return false;
}
const truncated_stream_name = stream_name.textContent ?? "";
instance.setContent(truncated_stream_name);
return undefined;
},
});
tippy.delegate("body", {
target: ".tippy-left-sidebar-tooltip",
placement: "right",