Use Enter in Autocomplete within dialog without firing primary button action

We've build an custom Autocomplete component (because yours only accept simpel data-types), and when we select an option from the list with Enter the primairy button action fires and the dialog will close. 

I've attached an example with an simplefied own component and your Autocomplete component and in both components the dialog closses when I press enter within. Despite the stopPropagation attribute on onkeypress and onkeydown in our own component. 

Best regards, Jaap

Attachment: BlazorApp1_aa3f1b3.rar

3 Replies

PM Pandiyaraj Muniyandi Syncfusion Team May 29, 2020 09:46 AM UTC

Hi Jaap van Vliet, 
 
Greetings from Syncfusion support. 
 
As per Dialog component behavior, we will manually invoke click action to primary button, which is rendered inside the footer section, when dialog contains focusable element in content section. You can prevent the default behavior using Dialog Opened event argument by passing true as value to PreventFocus property as follows 
 
 
<SfDialog> 
    <DialogEvents Opened="@DialogOpened"></DialogEvents> 
</SfDialog> 
 
@code { 
    private void DialogOpened(OpenEventArgs args) 
    { 
        args.PreventFocus = true; 
    } 
} 
 
 
We have modified your sample with above changes, get it from below link 
 
Regards, 
Pandiyaraj 



JV Jaap van Vliet May 29, 2020 10:02 AM UTC

Thanks!


PM Pandiyaraj Muniyandi Syncfusion Team May 29, 2020 10:24 AM UTC

Hi Jaap van,

Most Welcome! 
  
Regards, 
Pandiyaraj 


Loader.
Up arrow icon