Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
REFACTOR: rewrite the emoji-picker (discourse#10464)
Browse files Browse the repository at this point in the history
The emoji-picker is a specific piece of code as it has very strong performance requirements which are almost not found anywhere else in the app, as a result it was using various hacks to make it work decently even on old browsers.

Following our drop of Internet Explorer, and various new features in Ember and recent browsers we can now take advantage of this to reduce the amount of code needed, this rewrite most importantly does the following:
- use loading="lazy" preventing the full list of emojis to be loaded on opening
- uses InterserctionObserver to find the active section
- limits the use of native event listentes only for hover/click emojis (for performance reason we track click on the whole emoji area and delegate events), everything else is using ember events
- uses popper to position the emoji picker
- no jquery code
  • Loading branch information
jjaffeux authored Aug 24, 2020
1 parent 9debfed commit 226be99
Show file tree
Hide file tree
Showing 13 changed files with 499 additions and 930 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/discourse-shims.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ define("message-bus-client", ["exports"], function(__exports__) {
define("ember-buffered-proxy/proxy", ["exports"], function(__exports__) {
__exports__.default = window.BufferedProxy;
});

define("@popperjs/core", ["exports"], function(__exports__) {
__exports__.default = window.Popper;
__exports__.createPopper = window.Popper.createPopper;
__exports__.defaultModifiers = window.Popper.defaultModifiers;
__exports__.popperGenerator = window.Popper.popperGenerator;
});
4 changes: 1 addition & 3 deletions app/assets/javascripts/discourse/app/components/d-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,7 @@ export default Component.extend({
return `${v.code}:`;
} else {
$editorInput.autocomplete({ cancel: true });
this.setProperties({
emojiPickerIsActive: true
});
this.set("emojiPickerIsActive", true);

schedule("afterRender", () => {
const filterInput = document.querySelector(
Expand Down
Loading

0 comments on commit 226be99

Please sign in to comment.