Unplanned
Last Updated: 02 Jul 2024 05:50 by ADMIN
Miroslav
Created on: 06 Nov 2023 16:56
Category: ComboBox
Type: Bug Report
4
When AllowCustom = true ValueChanged is not fired if the new input matches an item from the list

Reproduction: https://blazorrepl.telerik.com/cHbFYUFq53Ext4Yt24.

Steps to reproduce:

  1. Open popup.
  2. Use the keyboard to navigate to the first item.
  3. Type "1", so the input value is "item11" (a value that matches an item from the list) -> ValueChanged is not fired.
  4. Type "1" again, so the input value is "item111" (this is a custom value not present in the list) -> ValueChanged is fired.
  5. Delete the last "1", so the input value is again "item11"(a value that matches an item from the list) -> ValueChanged is not fired.

===

TELERIK EDIT: A possible workaround is to obtain the typed string in OnChange and check if it is matching an item in the datasource:

https://blazorrepl.telerik.com/QyPEQXkV25A7VFyf50

1 comment
ADMIN
Yanislav
Posted on: 26 Jun 2024 10:52

Hello Everyone,

We are currently working on this item, and the behavior does seem inconsistent. I am unsure whether it is correct to change the value on each keystroke. Generally, the ValueChanged event should be triggered when the value of the component is actually changed (i.e., when an item is selected).

Currently, if the inserted text is not part of the dataset, the Combobox component updates its value, and the ValueChanged event is triggered. However, if there is an option that exactly matches the inserted text, the Combobox does not trigger the ValueChanged event since the value of the component is not updated. Instead, the dataset is just filtered, and the component waits for the user to select an item.

With that said, I wanted to ask about your specific use case. If the goal is to track the inserted value in the HTML input element, it might be best to expose an additional event like OnInput or FilterChanged, triggered each time the Combobox input element value changes, not just when the selected value changes. These are essentially different things.

Additionally, we think changing the component's value on each input change is problematic. You might have logic inside the ValueChanged handler that performs certain operations with the inserted value (like saving it to a database for later use in the dataset) but does not select it. For example, if you want to save the value 'AB', you will also trigger the ValueChanged event with the value 'A' since both might not be part of the current dataset. Therefore, it might be better to trigger the value change only on Enter or when the field is blurred (similar to how the OnChange event of the Combobox currently works). However, this is a separate issue we will consider.

That being said, we will consider redesigning this behavior, and your input will be highly appreciated. Thank you in advance!

Regards,
Yanislav
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!