fritx / vue-at

At.js for Vue.
https://fritx.github.io/vue-at/
MIT License
529 stars 114 forks source link

How to remove the suggestions on already selected values on page load #64

Closed Stacey940 closed 6 years ago

Stacey940 commented 6 years ago

Hi,

Thank you guys for putting efforts on creating this awesome plugin. This works great. I have only one problem. Whenever I reload the page it highlights all already selected values on the screen. I want to remove those so they will appear only when the textarea is selected or the field is selected Please check below image

image

fritx commented 6 years ago

image

Ah, Github has the same behavior too, which could make sense! It gives us the user a chance to press enter and get the necessary trailing space appended without manually adding it! xD

I added a prop showUnique(=true/false) and tested like the following (a little weird code): https://github.com/fritx/vue-at/blob/dev/src/At.vue#L311-L315

     const name = itemName(v)
     return filterMatch(name, chunk, at)
   })

+  show = false
   if (matched.length) {
+    show = true
+    if (!showUnique) {
+      let item = matched[0]
+      if (chunk === itemName(item)) {
+        show = false
+      }
+    }
+  }

+  if (show) {
     this.openPanel(matched, range, index, at)
   } else {
     this.closePanel()

Any thoughts? Better naming or logic and PR is welcomed :D

Stacey940 commented 6 years ago

@fritx Sorry for the late reply. Yes, I tried the code you provided above, but it doesn't seems to resolve the issue. Maybe I am messing something up on recompiling the modules.

Stacey940 commented 6 years ago

@fritx can you let me know the steps so I can resolve this. I am new to vue js and node . Can't figure it out . Should I open a PR request to add this feature? Thanks!

Stacey940 commented 6 years ago

Resolved issue . thanks!!

fritx commented 6 years ago

Sorry that I hadn't merged that branch yet before. If I confirm the branch is ok I would merge it xD How did you solve that?

Stacey940 commented 6 years ago

@fritx Yes, I am waiting on that release. I did tried above code but it did't worked. I added timeout on page load and set the at keyword 10 seconds after the page loads. That temporally resolved the issue.

Sorry for the delay in replying