mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
message-edit-tooltips: Fix the breaking tooltips on rerender.
Fixes: #35217.
This commit is contained in:
committed by
Tim Abbott
parent
6341bf192d
commit
074850ef5d
@@ -51,37 +51,40 @@ export function clean_up_compose_singleton_tooltip(context: SingletonContext): v
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initialize_compose_tooltips(context: SingletonContext, selector: string): void {
|
export function initialize_compose_tooltips(context: SingletonContext, selector: string): void {
|
||||||
// Clean up existing instances first
|
// Listen on body for the very first mouseenter on any element matching `selector`
|
||||||
clean_up_compose_singleton_tooltip(context);
|
$(document.body).one("mouseenter", selector, () => {
|
||||||
|
// Clean up existing instances first
|
||||||
|
clean_up_compose_singleton_tooltip(context);
|
||||||
|
|
||||||
const tooltip_instances = tippy.default(selector, {
|
const tooltip_instances = tippy.default(selector, {
|
||||||
trigger: "mouseenter",
|
trigger: "mouseenter",
|
||||||
appendTo: () => document.body,
|
appendTo: () => document.body,
|
||||||
placement: "top",
|
placement: "top",
|
||||||
});
|
});
|
||||||
|
|
||||||
const singleton_instance = tippy.createSingleton(tooltip_instances, {
|
const singleton_instance = tippy.createSingleton(tooltip_instances, {
|
||||||
delay: LONG_HOVER_DELAY,
|
delay: LONG_HOVER_DELAY,
|
||||||
appendTo: () => document.body,
|
appendTo: () => document.body,
|
||||||
onTrigger(instance, event) {
|
onTrigger(instance, event) {
|
||||||
const currentTarget = event.currentTarget;
|
const currentTarget = event.currentTarget;
|
||||||
if (currentTarget instanceof HTMLElement) {
|
if (currentTarget instanceof HTMLElement) {
|
||||||
const content = get_tooltip_content(currentTarget);
|
const content = get_tooltip_content(currentTarget);
|
||||||
if (content) {
|
if (content) {
|
||||||
instance.setContent(content);
|
instance.setContent(content);
|
||||||
|
}
|
||||||
|
if (currentTarget.classList?.contains("disabled-on-hover")) {
|
||||||
|
instance.setProps({delay: SINGLETON_INSTANT_HOVER_DELAY});
|
||||||
|
} else {
|
||||||
|
instance.setProps({delay: SINGLETON_LONG_HOVER_DELAY});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (currentTarget.classList?.contains("disabled-on-hover")) {
|
},
|
||||||
instance.setProps({delay: SINGLETON_INSTANT_HOVER_DELAY});
|
});
|
||||||
} else {
|
|
||||||
instance.setProps({delay: SINGLETON_LONG_HOVER_DELAY});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
compose_button_singleton_context_map.set(context, {
|
compose_button_singleton_context_map.set(context, {
|
||||||
tooltip_instances,
|
tooltip_instances,
|
||||||
singleton_instance,
|
singleton_instance,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user