Under Review
Last Updated: 27 Feb 2022 09:54 by ADMIN
Ting
Created on: 25 Feb 2022 23:27
Type: Feature Request
1
AutoComplete onItemClick/onItemSelect event

Feature request

I am using the `AutoComplete` component to implement a search input and I want to be notified when the user selects an item (via mouse click or keyboard navigation) from the popup list.

I found an undocumented prop `handleItemSelect` on the `AutoCompleteHandle` ref object, and used it to implement my feature successfully.

Please can you expose `handleItemSelect` as an event on the `AutoCompleteProps` API.

1 comment
ADMIN
Konstantin Dikov
Posted on: 27 Feb 2022 09:54

Hi Ting,

I have converted this to a feature request, so it can be visible in our feedback portal, where other developers can vote for the item.

As a side note, the reason that the AutoComplete do not have an onItemSelect event that exposes the selected item is due to the fact that the suggestions are only helpers in the context of the AutoComplete and when a value is changed, the onChange event fires with the new value. The same applies to the ComboBox for example, with the only difference that the onChange event of the ComboBox can return an object, whereas the AutoComplete will return only string values.

I would also suggest that you avoid using internal methods when possible, because breaking changes might easily occur in them. With that in mind, instead of using the "handleItemSelect", you can use the "onChange" event and manually search if the value is contained within the data bound to the AutoComplete. This will allow you to find the corresponding item within the onChange vent without relying on internal methods.

 

Regards,
Konstantin Dikov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.