Select all the content of DatePicker on click

1 Answer 23 Views
DateInput DatePicker DateTimePicker
neelima
Top achievements
Rank 1
neelima asked on 29 Feb 2024, 05:10 PM

When user click on the input field of DatePicker, it either select date, or month, or year, but we want to select whole date input field like it highlights/selects whole content on Tab key.

Tried  with the following code but still no luck.

<span @onfocusin="@FocusHandler">
    <TelerikDatePicker @bind-Value="@SelectedDate"
                       Min="@Min"
                       Max="@Max"
                       Format="MM/dd/yyyy"
                       DebounceDelay="@DebounceDelay"
                       ShowWeekNumbers="true"
                       @ref="@DateRef">
                       <DatePickerFormatPlaceholder Day="day" Month="month" Year="year" />
    </TelerikDatePicker>
    </span>

@code {
    private DateTime? SelectedDate { get; set; }
    private DateTime Max = new DateTime(2050, 12, 31);
    private DateTime Min = new DateTime(1950, 1, 1);
    private int DebounceDelay { get; set; } = 200;
    private TelerikDatePicker<DateTime?> DateRef { get; set; }
    private async Task FocusHandler()
    {
        await DateRef.FocusAsync();
    }
}

 

It gets selected on buttonclick though (code snippet below where it selects all content on button click) - 

<TelerikButton OnClick="@FocusHandler">Focus Date</TelerikButton>
    <TelerikDatePicker @bind-Value="@SelectedDate"
                       Min="@Min"
                       Max="@Max"
                       Format="MM/dd/yyyy"
                       DebounceDelay="@DebounceDelay"
                       ShowWeekNumbers="true"
                       @ref="@DateRef">
                       <DatePickerFormatPlaceholder Day="day" Month="month" Year="year" />
    </TelerikDatePicker> 
@code {
    private DateTime? SelectedDate { get; set; }
    private DateTime Max = new DateTime(2050, 12, 31);
    private DateTime Min = new DateTime(1950, 1, 1);
    private int DebounceDelay { get; set; } = 200;
    private TelerikDatePicker<DateTime?> DateRef { get; set; }
    private async Task FocusHandler()
    {
        await DateRef.FocusAsync();
    }
}

 

Any help would be appreciated! TIA.

-Neelima

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristian Stefanov
Telerik team
answered on 29 Feb 2024, 05:58 PM

Hi Neelima,

A feature request for the desired functionality to highlight the entire content in the date input has already been submitted on our public feedback portal: Always highlight / select all content of the input on focus. This enhancement is already scheduled for around May (Q2 this year).

You can subscribe to the public item to receive email notifications for further status updates.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Tags
DateInput DatePicker DateTimePicker
Asked by
neelima
Top achievements
Rank 1
Answers by
Hristian Stefanov
Telerik team
Share this question
or