Combo Box Focus Out event not working properly

Hello,

I'm using Syncfusion version 18.4.0.32
In the Combobox, it's clear that the "FocusOut" function is not implemented correctly when called by the "OnClose" event.

Setup: Both Combo Box events "OnClose" and "OnValueSelect" call the same function for "FocusOut"
Expected: The combo box should no longer be in focus after either (a) a value is selected or (b) the drop down is closed
Actual: If (a) occurs, then the combo box is no longer in focus. However if (b) occurs, then the combo box remains in focus unintentionally.


I figured out a workaround is to add a "Task.Yield()" statement prior to calling the "FocusOut()" function.
Once this is done, the focus is removed as expected in both (a) and (b).
Please see the attached code for example.

Attachment: ComboBoxTest_d109f89e.zip

3 Replies 1 reply marked as answer

VS Vignesh Srinivasan Syncfusion Team February 22, 2021 08:56 AM UTC

Hi Sorin, 
 
Greetings from Syncfusion Support. 
 
The focusOut() method does not work without time delay it is because in our end when the popup close, we manually trigger the focusIn() method again in the source. After the focusOut() method call without time delay the component loss the focus and it again get focusIn() from our end in source. So, we suggest you to use the Task.Delay() in application. 
 
Please let us know if you need any further assistance. 
 
Regards, 
 
Vignesh Srinivasan. 


Marked as answer

AK Alexey Kazakevich replied to Vignesh Srinivasan December 8, 2021 05:11 PM UTC

How to disable this FocusIn() ???

I spent a day trying to remove the focus from the input field and did not succeed

The proposed solutions do not work:

await Task.Yield();

await SfComboBox.FocusOutAsync();


or


await SfComboBox.FocusOutAsync();

await Task.Delay(1000);


or


await Task.Yield();

await SfComboBox.FocusOutAsync();

await Task.Delay(1000);




BC Berly Christopher Syncfusion Team December 9, 2021 05:05 PM UTC

Hi Alexey Kazakevich, 
  
We can achieve the requested requirement with help of Thread.Sleep() as mentioned in the below code example in the Closed event.  
  
<SfComboBox @ref="@ComboBox1" TItem="Countries" TValue="string" Placeholder="e.g. Australia" @bind-Value="@ComboVal" DataSource="@Country"> 
    <ComboBoxFieldSettings Value="Name"></ComboBoxFieldSettings> 
    <ComboBoxEvents TValue="string" TItem="Countries" Closed="@DeFocusComboBox" OnValueSelect="@DeFocusComboBox"></ComboBoxEvents> 
</SfComboBox> 
public async Task DeFocusComboBox() 
    { 
        Thread tread = new Thread( 
             async () => 
             { 
                 Thread.Sleep(15); 
                 await ComboBox1.FocusOutAsync(); 
             } 
          ); 
        tread.Start(); 
        await Task.CompletedTask;        
    } 
 
  
  
  
Regards, 
Berly B.C 


Loader.
Up arrow icon