# EmojiPicker stores state in global module-level variables

**URL:** <https://meta.discourse.org/t/emojipicker-stores-state-in-global-module-level-variables/70056>\
**Category:** Bug\
**Created:** [September 14, 2017, 3:44pm UTC](https://meta.discourse.org/t/emojipicker-stores-state-in-global-module-level-variables/70056 "2017-09-14T15:44:03Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)\
**Post date:** [September 14, 2017, 3:44pm UTC](https://meta.discourse.org/t/emojipicker-stores-state-in-global-module-level-variables/70056/1 "2017-09-14T15:44:03Z")

</div>

In `emoji-picker.js.es6`:

The following variables are used for emoji-pickers, but they are currently module- **GLOBAL** variables instead of instance fields.

`let $picker, $filter, $results, $list, scrollPosition, $visibleSections, _checkTimeout;`

In particker, `$picker` is used to popup the emoji-picker. It is a module-global variable, so what that means is that there CANNOT BE any permanent emoji-picker’s on the page (e.g. `discourse/babble` and `discourse/retort` both put emoji-pickers permanently on the page).

When the compose-reply window is open, the standard emoji picker is created, overwriting `$picker` for everybody, causing all permanent emoji-pickers on the page to break.

Suggestion is to move all these variables into the class definition, and make them instance-specific fields. This should then allow for multiple emoji-pickers to co-exist on the same page with conflicts.

---

_[View the full topic](https://meta.discourse.org/t/emojipicker-stores-state-in-global-module-level-variables/70056)._
