[Bug]: Rich text editor (Beta): with an inline edit open, typing or pasting outside a text box goes into the edited post instead of the message box
Mattermost Server Version
11.10.2 (Team Edition), feature flag WysiwygEditor enabled, user setting "Rich text editing (Beta)" on
Operating System
Windows 10, Desktop App 6.3.0 (where our user hit it); also reproduced in Chrome on macOS (web app)
Steps to reproduce
- Turn on Settings > Advanced > Rich text editing (Beta).
- In any channel or DM, open the inline edit box on one of your earlier posts (post menu > Edit, or press Up arrow in the empty message box).
- Do not save or cancel. Click somewhere in the post list outside any text box, for example on a date separator.
- Type some text (for example
XYZ) or paste a link with Ctrl+V.
Expected behavior
The text goes to the main message box at the bottom, the same as with Markdown editing.
Observed behavior
The text goes into the open inline edit box and is inserted at the very beginning of the old message (typing XYZ turned TEST2 ... into YZTEST2 ...). The first keystroke is lost. The main message box stays empty.
Our user described it as "everything I type gets inserted at the top of the message I edited, and I can't write a new message". If she presses Enter at that point, the old post is overwritten instead of a new one being sent.
- Esc or Cancel closes the edit box, and typing goes to the main box again.
- With Markdown editing (rich text off), the same steps send the text to the main message box, with nothing lost.
- Switching the user's preference to Markdown editing fixes an already open client immediately, even with the edit box still open.
Log Output
No server errors. All posts are stored correctly; this is client-side only.Additional Information
Likely cause, from reading the v11.10.2 source:
- Every AdvancedTextEditor instance (the center one and the inline edit one) registers a document keydown listener in
use_textbox_focus.tsx. shouldFocusMainTextbox()inutils/post_utils.tsreturns true for printable keys and for Ctrl+V when focus is outside an input or contenteditable.- The inline edit editor registers last, so its listener wins.
PR #37815 only covers the case where focus is already inside a contenteditable. The logic looks the same in v11.11.1 and master.
Related, separate problem: pasting a link copied with underline formatting stores it as ++[url](url)++. Tiptap's Underline mark is still enabled in StarterKit, and Mattermost markdown does not render ++.
For now we switched rich text editing off for all our users.
Source: mattermost/mattermost