Skip to content

[Double-click-to-edit] Double-clicking inside the edit textbox re-triggers edit mode and resets the message #182

@Nathack-dev

Description

@Nathack-dev

Describe the bug

Bug

When double-clicking a message to enter edit mode, then double-clicking again inside the edit textbox (e.g. to select a word), the dblclick handler fires again and calls startEditMessage(), which resets the edit content.

The existing guard (messageDiv.classList.contains(this.selectedClass)) does not catch this case because the click target is inside the textbox, which still resolves to the same message <li>.

Expected behavior

Double-clicking inside the edit textbox should only perform normal text selection, not re-trigger the edit handler.

Suggested fix #vibecoding

Add an early return in handler() if the event target is inside an editable element:

handler(e) {
    // Ignore double-clicks inside edit areas
    if (e.target.closest('[role="textbox"], textarea, input, [contenteditable="true"]'))
        return;
    // ... rest of handler
}

### Expected behavior

When a message is already in edit mode, double-clicking inside the edit textbox should only select text (normal browser behavior) and should not re-trigger `[startEditMessage()]`, which resets the edit content and loses any changes in progress.

### To reproduce

1. Double-click on one of your own messages to enter edit mode.
2. Once the edit textbox appears, double-click inside it (e.g. to select a word).
3. The edit is reset: `[startEditMessage()]` fires again with the original content, discarding any changes you may have started typing.

### Screenshots

_No response_

### OS version

Windows 11 64-bit (10.0.26200)

### Discord version

Stable 526941 (5366f7c)

### BetterDiscord version

Stable 1.13.11 (65705d6)

### Plugin version

v9.4.10

### Additional context

_No response_

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions