When using "native device emoji", selecting an emoji autocomplete entry with the keyboard fails and triggers JavaScript error

Steffen

Well-known member
Affected version
2.3.7
How to reproduce:

  1. Open a XenForo installation that uses the emoji style "Native device emoji" (which means that it cannot be reproduced here on xenforo.com at the moment)
  2. Go to any message editor (i.e. reply to a thread) and ensure that the editor is in WYSIWYG mode (the issue doesn't exist in BBCode mode because this mode uses a different autocomplete code path)
  3. Enter some kind of text that triggers the emoji autocomplete to appear, e.g. ":go"
  4. Press the Enter key to insert the suggested emoji (the issue doesn't exist when using the mouse for some reason)

What should happen:

Emoji is inserted.

What actually happens:

A newline character is inserted and a JavaScript error is logged:

"Uncaught TypeError: Cannot read properties of null (reading 'dataset')"

This is triggered by the following line in editor.js because when using native device emoji there are no "img" elements in the autocomplete results:

JavaScript:
XF.logRecentEmojiUsage(el.querySelector('img.smilie').dataset.shortname)

This issue most likely exists since XenForo 2.3 and the migration from jQuery to vanilla JavaScript.
 
Back
Top Bottom