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.
This commit is contained in:
Trident Pancake 2023-05-07 00:02:34 -07:00 committed by Tim Abbott
parent f11350f789
commit e52eee330c
1 changed files with 4 additions and 0 deletions

View File

@ -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;