From e52eee330cbf8a2096aeb0c7be48a69648844043 Mon Sep 17 00:00:00 2001 From: Trident Pancake Date: Sun, 7 May 2023 00:02:34 -0700 Subject: [PATCH] message_edit: Avoid registering duplicate events. Fixes #25462. hotkey.js is the file that handles the 'e' keyboard shortcut. It maps to the 'edit_message' event and will simply call message_edit.start(). message_edit.start() doesn't check whether it's already been opened previously, so it will go through and try to register handler for the clipboard button again. When the clipboard button gets clicked, the handler will be called twice. Once with a properly target element, and once with null. Fix this issue by checking if message_edit.start() has already operated on the given $row. --- web/src/message_edit.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/src/message_edit.js b/web/src/message_edit.js index bcfe9d8945..b9a3cc7b9e 100644 --- a/web/src/message_edit.js +++ b/web/src/message_edit.js @@ -590,6 +590,10 @@ export function start($row, edit_box_open_callback) { return; } + if ($row.find(".message_edit_form form").length !== 0) { + return; + } + if (message.raw_content) { start_edit_with_content($row, message.raw_content, edit_box_open_callback); return;