mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-19 14:40:26 +08:00
fix(composer-emoji): Return null if no matching node is found
This commit is contained in:
parent
a8e5d9948e
commit
be9c616840
1 changed files with 3 additions and 1 deletions
|
@ -80,8 +80,9 @@ class EmojiComposerExtension extends ContenteditableExtension {
|
|||
if (event.key === "ArrowDown" || event.key === "ArrowRight" ||
|
||||
event.key === "ArrowUp" || event.key === "ArrowLeft") {
|
||||
event.preventDefault();
|
||||
const moveToNext = (event.key === "ArrowDown" || event.key === "ArrowRight")
|
||||
const moveToNext = (event.key === "ArrowDown" || event.key === "ArrowRight");
|
||||
const emojiNameNode = DOMUtils.closest(sel.anchorNode, "n1-emoji-autocomplete");
|
||||
if (!emojiNameNode) return null;
|
||||
const selectedEmoji = emojiNameNode.getAttribute("selectedEmoji");
|
||||
if (selectedEmoji) {
|
||||
const emojiIndex = emojiOptions.indexOf(selectedEmoji);
|
||||
|
@ -100,6 +101,7 @@ class EmojiComposerExtension extends ContenteditableExtension {
|
|||
} else if (event.key === "Enter" || event.key === "Tab") {
|
||||
event.preventDefault();
|
||||
const emojiNameNode = DOMUtils.closest(sel.anchorNode, "n1-emoji-autocomplete");
|
||||
if (!emojiNameNode) return null;
|
||||
let selectedEmoji = emojiNameNode.getAttribute("selectedEmoji");
|
||||
if (!selectedEmoji) selectedEmoji = emojiOptions[0];
|
||||
EmojiComposerExtension._onSelectEmoji({editor: editor,
|
||||
|
|
Loading…
Reference in a new issue