Explorar o código

Fix error on emoji picker first load

Ref: grouped-emoji-picker
Tusooa Zhu %!s(int64=3) %!d(string=hai) anos
pai
achega
c93da0b865
Modificáronse 1 ficheiros con 15 adicións e 5 borrados
  1. 15 5
      src/components/emoji_picker/emoji_picker.js

+ 15 - 5
src/components/emoji_picker/emoji_picker.js

@@ -133,6 +133,18 @@ const EmojiPicker = {
           this.$lozad.mutationObserver.disconnect()
         }
       }
+    },
+    onShowing () {
+      const oldContentLoaded = this.contentLoaded
+      this.contentLoaded = true
+      this.waitForDomAndInitializeLazyLoad()
+      if (!oldContentLoaded) {
+        this.$nextTick(() => {
+          if (this.defaultGroup) {
+            this.highlight(this.defaultGroup)
+          }
+        })
+      }
     }
   },
   watch: {
@@ -145,16 +157,14 @@ const EmojiPicker = {
     },
     showing (val) {
       if (val) {
-        this.contentLoaded = true
-        this.waitForDomAndInitializeLazyLoad()
+        this.onShowing()
       }
     }
   },
   mounted () {
-    if (this.defaultGroup) {
-      this.highlight(this.defaultGroup)
+    if (this.showing) {
+      this.onShowing()
     }
-    this.waitForDomAndInitializeLazyLoad()
   },
   destroyed () {
     this.destroyLazyLoad()