DateRangePicker FocusOut is not working

Hello,

SfDateRangePicker.FocusOut method is not working.

Attached is the sample project. You will see that thee DateRangePicker is not losing focus.

Thanks,
Ahmet.

<SfDateRangePicker @ref="_dateRangePicker" TValue="DateTime?"
Placeholder="Choose a Range"
AllowEdit="false">
<DateRangePickerEvents TValue="DateTime?" OnClose="OnCloseHandler">DateRangePickerEvents>


SfDateRangePicker>
@code {

private SfDateRangePicker<DateTime?> _dateRangePicker;

private void OnCloseHandler(RangePopupEventArgs args)
{
Console.WriteLine("OnClose");
_dateRangePicker.FocusOut();
}


}

Attachment: Blazor_daterange1767708411_7ced9614.zip

5 Replies 1 reply marked as answer

VS Vignesh Srinivasan Syncfusion Team February 3, 2021 12:27 PM UTC

Hi Ahmet, 
 
Greetings from Syncfusion support.  
 
We can be able to focus out the DateRangePicker component on popup close using the OnClose event with Task.Delay(). Please find the code below. 
 
Code snippet: 
 
<SfDateRangePicker @ref="@_dateRangePicker" TValue="DateTime?" 
                   Placeholder="Choose a Range" 
                   AllowEdit="false"> 
    <DateRangePickerEvents TValue="DateTime?" OnClose="OnCloseHandler"></DateRangePickerEvents> 
 
 
</SfDateRangePicker> 
@code { 
 
    public SfDateRangePicker<DateTime?> _dateRangePicker; 
 
    private async void OnCloseHandler(RangePopupEventArgs args) 
    { 
        await Task.Delay(1000); 
        Console.WriteLine("OnClose"); 
        this._dateRangePicker.FocusOut(); 
    } 
} 
 
 
 
Kindly check with the above sample. Please let us know if you need any further assistance. 
 
Regards, 
 
Vignesh Srinivasan. 
 
 


Marked as answer

AH Ahmet February 3, 2021 02:07 PM UTC

Thanks, I didn't understand why we need a delay, tough.


VS Vignesh Srinivasan Syncfusion Team February 4, 2021 06:16 AM UTC

Hi Ahmet, 
 
You are welcome. 
 
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 to use the Task.Delay() in application. 
 
Please let us know if you need any further assistance. 
 
Regards, 
 
Vignesh Srinivasan. 



AH Ahmet February 4, 2021 12:02 PM UTC

Got it. Thanks for the explanation.


VS Vignesh Srinivasan Syncfusion Team February 5, 2021 05:01 AM UTC

Hi Ahmet, 
 
Thanks for the update. Please let us know if you need any further assistance. 
 
Regards, 
Vignesh Srinivasan. 


Loader.
Up arrow icon