Hi,
please see the example: https://stackblitz.com/edit/syncfusion-multi-select-issue-2?file=index.js
When I select any value then the selected value appears twice in MultiSelectComponent. What am I doing wrong here? My goal is to have a tag input where also custom tags can be added beside existing tags. For new tag names I would like to trim whitespaces, i.e. the entered name will not always match the tag name I add.
Regards, Steffen Harbich
function onChange(e) {
setSelected(e.value);
}
return (
<p>
<MultiSelectComponent
dataSource={ds}
fields={{ text: 'name', value: 'id' }}
allowFiltering={true}
filterType="Contains"
sortOrder="Ascending"
showClearButton={true}
allowCustomValue={true}
value={selected}
changeOnBlur={false}
change={onChange}
removed={removeTag}
/>
</p>
);
} |
Ok, the "change" event is somehow better as it does not produce the behavior of duplication. Will the actual bug be fixed?
And how can I implement that new values (entered by user) are recognized and stored within the react state?
Query 1: Please have a look at my original example. I did not bound the complex object to the MultiSelect. Instead I bound the ID (if it was an existing object) or the name (if it was a newly entered tag). IMO it is a bug and should be fixed.
Query 2: The printed value in console is probably randomly generated ID of a new value (non existing before). How does that help me? I need the text of the new value.
function customValue(e) {
console.log(e.newData.name);
}
|
Hi,
regarding query1: I did not talk about the state variable. See the code:
Clearly, the state variable isn't bound directly to the component but mapped to name (string) if it is a new tag and to id (number) if it is an existing tag.
Regards, Steffen