This is a migrated thread and some comments may be shown as answers.

RadAutoCompleteView selects first item in list when return is hit on keyboard

7 Answers 125 Views
AutoCompleteView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Veteran
Stephen asked on 01 Apr 2021, 01:47 PM

So I am getting the "selected item" like so 

 

<input:RadAutoCompleteView.Behaviors>
     <xct:EventToCommandBehavior     Command="{Binding CommandEquipmentListItemSelected}" EventName="SuggestionItemSelected" />
</input:RadAutoCompleteView.Behaviors>

 

Then in my view model I cast it like so ...

if (arg is null) return;
                   var tmpRadRadAutoCompleteView = arg as SuggestionItemSelectedEventArgs;
 
                   if (tmpRadRadAutoCompleteView.DataItem is not null)
                   {
                       JCJob job = (JCJob)tmpRadRadAutoCompleteView.DataItem;

 

Which works fine ... until .. the user hit's the return key on the keyboard ... 

It then fires the command again and selects (passes in) the first item in the list .... 

Obviously this is not desired behavior .... 

 

7 Answers, 1 is accepted

Sort by
0
Stephen
Top achievements
Rank 1
Veteran
answered on 01 Apr 2021, 03:16 PM

Here are the packages / versions in use ...

 

    <PackageReference Include="Telerik.UI.for.Xamarin.Common" Version="2021.1.325.1" />
    <PackageReference Include="Telerik.UI.for.Xamarin.DataControls" Version="2021.1.325.1" />
    <PackageReference Include="Telerik.UI.for.Xamarin.DataGrid" Version="2021.1.325.1" />
    <PackageReference Include="Telerik.UI.for.Xamarin.Input" Version="2021.1.325.1" />
    <PackageReference Include="Telerik.UI.for.Xamarin.Primitives" Version="2021.1.325.1" />
    <PackageReference Include="Telerik.UI.for.Xamarin.SkiaSharp" Version="2021.1.325.1" />
    <PackageReference Include="Xamarin.CommunityToolkit" Version="1.1.0" />
    <PackageReference Include="Xamarin.Essentials.Interfaces" Version="1.6.1" />
    <PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />  
    <PackageReference Include="Xamarin.Essentials" Version="1.6.1" />

0
Yana
Telerik team
answered on 02 Apr 2021, 11:41 AM

Hello Stephen,

I wasn't able to reproduce the reported behavior in RadAutoCompleteView with our latest version - SuggestionItemSelected event is fired when an item is selected from the dropdown list. Would it be possible to send me a little bit more information on the exact scenario you have, like the  AutoCompleteView definition and any related code?

Also on which platform do you reproduce the described behavior?

I look forward to your reply.

Regards,
Yana
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/.

0
Stephen
Top achievements
Rank 1
Veteran
answered on 02 Apr 2021, 12:10 PM

Can you provide your sample ?

I will try to put one together later today but I'm using MVVM so there is no SuggestionItemSelected event to fire 

 

0
Stephen
Top achievements
Rank 1
Veteran
answered on 02 Apr 2021, 01:40 PM

here is the popup being presented (Screenshot.png)

 

When I select the element "sdbdfsbdfsb" you can see from the debug output that it works ...

[0:] ***************************JobSuggestionSelectedCommand***************************
[0:] {"Id":"041d9bb1-5b88-4716-8124-3a54d72faa40","Text":"sdbdfsbdfsb item","Description":"This is an item description.","TextAndDescription":"sdbdfsbdfsb item - This is an item description."}
[0:] ****************************************************** 

 

then if I hit enter on the soft keyboard when the control is closed up you can see it fires again and selects the wrong one ..

[0:] ***************************JobSuggestionSelectedCommand***************************
[0:] {"Id":"7043d482-aac3-437f-9db9-8b742d91bdf7","Text":"Fppp item","Description":"This is an item description.","TextAndDescription":"Fppp item - This is an item description."}
[0:] ******************************************************

 

Since your forum does not allow zip files ....

https://github.com/stephenhauck/TelerikAutompleteTest

 

 

 

 

 

 

 

 

0
Stephen
Top achievements
Rank 1
Veteran
answered on 02 Apr 2021, 05:08 PM

Hello ?

 

0
Accepted
Yana
Telerik team
answered on 05 Apr 2021, 05:57 AM

Hello Stephen,

Thank you for sending the solution, it's been of great help.

The behavior you're observing is due to the SuggestMode property of the AutoCompleteView which is currently set to "SuggestAppend".  Let me explain in more details -  SuggestMode provides the following options:

  • Suggest (the default one) - provides a drop-down list of options for you to pick from;
  • Append - provides an inline display of the first suggestion.
  • SuggestAppend - combines the functionality of the two options above, shows a drop-down with suggestions and at the same time selects the first one from the list. 

So, basically, you would need to use the default "Suggest" SuggestMode.

I hope this would be helpful. Let me know if I can help with anything else.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Stephen
Top achievements
Rank 1
Veteran
answered on 05 Apr 2021, 10:07 AM
I just tried it on my example app and it seems to work, I will mark this as the answer once it is confirmed in my production code.
Tags
AutoCompleteView
Asked by
Stephen
Top achievements
Rank 1
Veteran
Answers by
Stephen
Top achievements
Rank 1
Veteran
Yana
Telerik team
Share this question
or