Skip to content

Commit

Permalink
Tweak emoji picker focus
Browse files Browse the repository at this point in the history
  • Loading branch information
rossant committed Mar 13, 2024
1 parent 17e1a03 commit 299beed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class Editor {
// Show/hide the emoji picker.
this.emojiButton.addEventListener("click", (e) => {
this.emojiPicker.classList.toggle("visible");

// Automatically focus the emoji picker search text box.
const input = app.model.editor.emojiPicker.shadowRoot.getElementById("search");
if (input)
input.focus();
});
}

Expand All @@ -48,6 +53,12 @@ class Editor {
this.emojiPicker.addEventListener('focusout', (e) => {
this.emojiPicker.classList.remove("visible");
});

// Hide the picker when pressing Escape.
this.emojiPicker.addEventListener('keydown', (e) => {
if (e.key == "Escape")
this.emojiPicker.classList.remove("visible");
});
}

setupColorButton() {
Expand Down

0 comments on commit 299beed

Please sign in to comment.