mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
tippy: Add message_list_tooltip helper to clear tooltips on rerender.
We've had a series of bugs where tooltips get leaked when a message list is rerendered. For some tooltips, we used a 'mutation observer' to remove the tooltip in this situation, but this was expensive and messy. We replace this with a Tippy plugin to keep track of this class of tooltips, with a central hook to remove them during rendering. Message lists are rerendered in the background in a variety of situations; a simple way to trigger it is clicking the mute/unmute topic/stream button in the topic menu/stream menu and the clickable area overlaps with the message list tooltips area. If a tooltip was visible at the time, the tooltip loses its reference due to the re-rendering removing its DOM element, appearing at the top-left corner. To prevent this behavior for all message list tooltips, we need to store all instances of the message list tooltips and then destroy them if the instances does refer to something else then document.body using the 'destroy_all_message_list_instances' function just before re-rendering. Whenever the message list is rendered, all the message list tooltips will be destroyed if they do not refer to document.body. This prevents the double appearance of those tooltips if the reference is removed from the DOM. This plugin allows us to remove the mutation observers and net delete code while hopefully fixing this bug for the whole app.
This commit is contained in:
@@ -10,6 +10,7 @@ import * as narrow_state from "./narrow_state";
|
||||
import {page_params} from "./page_params";
|
||||
import {web_mark_read_on_scroll_policy_values} from "./settings_config";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as tippyjs from "./tippyjs";
|
||||
import {user_settings} from "./user_settings";
|
||||
|
||||
export class MessageList {
|
||||
@@ -421,6 +422,9 @@ export class MessageList {
|
||||
}
|
||||
|
||||
rerender() {
|
||||
// We need to destroy all the tippy instances from the DOM before re-rendering to
|
||||
// prevent the appearance of tooltips whose reference has been removed.
|
||||
tippyjs.destroy_all_message_list_tooltips();
|
||||
// We need to clear the rendering state, rather than just
|
||||
// doing clear_table, since we want to potentially recollapse
|
||||
// things.
|
||||
|
||||
Reference in New Issue
Block a user