Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When adding any token from onTokenRemoved callback method, the added token also gets removed #378

Closed
maheshwariaanchal opened this issue Feb 25, 2019 · 6 comments
Labels

Comments

@maheshwariaanchal
Copy link

Hello,
When I remove any token by clicking cross image of the token, the callback method "onTokenRemoved" is called. Its working fine till here. Now in that method(onTokenRemoved) I am adding another token using method "MyCompletionView.addObjectAsync(list.get(0));"
This is the last line of that method. No more lines are there to be executed.
Whenever the token is added callbacks goes to "onTokenAdded" and after that the callback automatically again goes to "OnTokenRemoved" method, it executes from the very first line of that method for the newly added token and the newly added token is removed.

Please help. Its pretty urgent.
Thanks in advance.

@mgod
Copy link
Contributor

mgod commented Feb 25, 2019

Can you give me some more details on what you're actually trying to accomplish in the UI? Are you able to reproduce the issue with the sample project?

I can only imaging this happening if you are adding the same object that got removed, but I can't figure out how to reproduce this myself.

@maheshwariaanchal
Copy link
Author

Hi,
Thanks for the reply. Actually what I am trying to do is, I have a list of items and they can be multiselected or deselected.
So when I select some items from the list I show only the first selected item in completion view and write (+5 more, depending on the number of items selected) in front of that item. Now if the item which is shown in completion view is deselected by the user, I remove that item from the completion view and add one selected item from the remaining selected item list.

So while doing so the callback method "onTokenRemoved" is called when removing the item. At the same time when the call arrives in "onTokenRemoved" method, I add one token from the remaining selected items using the method MyCompletionView.addObjectSync(list.get(0)).
Now the callback method "onTokenAdded" is called. And from there "onTokenRemoved" is automatically for the newly added item.

However If I add token after some delay (around 3 sec), its working fine and the callback is not going to "onTokenRemoved" for the added token.

I have not reproduced it on the sample project.

Thanks.

@mgod
Copy link
Contributor

mgod commented Feb 26, 2019

It seems like that should work without the delay, but I might also try a different approach. I haven't updated the docs for this yet, but I don't expect these interfaces to change at this point. I would override shouldIgnoreToken and return true if the user is selecting an item in the list that is already in the view. When this happens, the onTokenIgnored listener callback will fire and I would then remove the token from the view and add the new random token. This might avoid the callback cycle you're currently stuck in.

@maheshwariaanchal
Copy link
Author

Thanks again. Sorry for the late reply. I didn't exactly get what you are trying to say. But I am still working on it. I have provided some delay when adding token and its working fine. I am still looking for some workaround. Please let me know if you get any solution for this.
Thanks

@mgod
Copy link
Contributor

mgod commented Mar 9, 2019

I've updated the docs for version 3.0.0, which might make my suggestion more clear.

@mgod mgod added the bug label Mar 9, 2019
@mgod
Copy link
Contributor

mgod commented Mar 9, 2019

Actually, on looking this over, I think this might be resolved by 3.0.0. Can you try it and let me know if you're still seeing the issue?

@mgod mgod closed this as completed Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants