New item not updating properly sometimes
Hi,
I have this MultiSelect control:
<SfMultiSelect TValue="int[]" TItem="Tag" @bind-Value="@SelectedTagIds"
Placeholder="Type tag name..." DataSource="@TagsAll" AllowCustomValue="true" EnableChangeOnBlur="false" Mode="@VisualMode.Box">
<MultiSelectEvents TValue="int[]" TItem="Tag"
ValueChange="@OnTagSelectionChanged"
CustomValueSpecifier="@OnCustomValueSpecifier"
>
</MultiSelectEvents>
<MultiSelectFieldSettings Text="Name" Value="Id"></MultiSelectFieldSettings>
</SfMultiSelect>
[Parameter]
public EventCallback<int[]> SelectedTagsChanged { get; set; }
[Parameter]
public Func<string, Task<Tag>>? NeedSaveNewItem { get; set; }
private async Task OnTagSelectionChanged(MultiSelectChangeEventArgs<int[]> args)
{
if (SelectedTagsChanged.HasDelegate)
{
await SelectedTagsChanged.InvokeAsync(SelectedTagIds);
}
}
private async Task OnCustomValueSpecifier(CustomValueEventArgs<Tag> args)
{
if (!string.IsNullOrWhiteSpace(args.Text) && NeedSaveNewItem is not null)
{
Tag tag = await NeedSaveNewItem(args.Text);
args.NewData = tag;
}
}
Sometimes (in a slower environment), the typed text (blue in image) and the new item in the dropdown list (red in image) are different.
The problem is, when I press enter then the "red" item will be saved not the "blue".
Can you help me please how can I syncronize this two items before save (to show equal values in red and blue boxes in image)?
Thank you!
BR, SZL
Attachment: MultiSelect_AllowCustom_d1c45d64.zip
Hi,
Thank you for the example. Your solution works fine.
I think additional operations that I do by event (and two-way binding, and slow computer) affected the behavior of the control.
Finally I disabled the inline add function for security reasons and created a form style 'add' new item.
Have a nice day!
Hi SZL
Thank you for the update. Please get back to us for assistance in the future.
Regards,
Shereen
- 3 Replies
- 3 Participants
-
SZ SZL
- Jul 30, 2025 01:56 PM UTC
- Aug 19, 2025 06:01 AM UTC