Closed RezaRahmati closed 4 years ago
@RezaRahmati, hi!
Seems to be a really bug for me, but you can change the logic of onCustomItemCreating callback function to prevent adding duplicate values.
@Bykiev can you please clone and modify my code, (as I tried before not able to do that)
@RezaRahmati, here is a sample of implementation of onCustomItemCreating function. I tried it, but it still resets all selected values, but prevents adding duplicate values to dataSource...
onCustomItemCreating(args) {
let newValue = args.text;
if (this.editableProducts.indexOf(newValue) == -1) {
this.editableProducts.unshift(newValue);
args.customItem = newValue;
}
}
@Bykiev yes, exactly, I tried it before too, just wanted to be sure we are on same page.
@RezaRahmati, it seems behaviour in https://github.com/DevExpress/DevExtreme/issues/12343#issuecomment-604974145 is correct, just try to type in already selected item, select it and it'll be removed from selection
@Bykiev I tried, still same behavior, tags will be removed check my updated sandbox https://codesandbox.io/s/overview-devextreme-tag-box-wmeb5?fontsize=14&hidenavigation=1&theme=dark
@RezaRahmati, not all tags will be removed, but only duplicated. I belive this behaviour is correct, check this demo with search mode and try to select item multiple times and it'll be remove from selection. But let's wait for offical response from DevExpress team
Hi all,
TagBox doesn't support duplicated tags. You can implement unique keys for each item if you wish to have the same display text for them. Please test the following example: https://codesandbox.io/s/overview-devextreme-tag-box-9xtz3
Alternatively, you need to validate values before applying them. Please refer to DxTagBox generates duplicate items when acceptCustomValue equals true where we discussed this task.
@artem-kurchenko Hi Artem, I don't know why I missed your response.
What I want is if user enters an item that already exists, don't do anything, right now it removes it, even with checking in onCustomItemCreating
How can I implement this behavior?
@artem-kurchenko Hi Artem, I don't know why I missed your response.
What I want is if user enters an item that already exists, don't do anything, right now it removes it, even with checking in onCustomItemCreating
How can I implement this behavior?
Did you ever manage to figure this out? Banging my head against the wall right now, trying to do the same.
@artem-kurchenko Hi Artem, I don't know why I missed your response. What I want is if user enters an item that already exists, don't do anything, right now it removes it, even with checking in onCustomItemCreating How can I implement this behavior?
Did you ever manage to figure this out? Banging my head against the wall right now, trying to do the same.
No, unfortunately
Is there any update on this ticket? Having the same issue as described in the original ticket submission. If two duplicate custom items are added, I want the tagbox to only keep one of the tags, not remove them both entirely...
I am also facing the same issue. If someone enters a custom tag twice, why are both values removed? It should only remove the duplicate.
Steps to Reproduce:
test
in tag box, confirm it shows thetest
test
againResults You Received:
Both
test
tags are removed (also both are removed from valueChange event argument)Results You Expected:
It shows both
test
, or if it doesn't let duplicates should keep one of themEnvironment Details:
Devexterme: 19.2.6