Unplanned
Last Updated: 05 Sep 2024 15:07 by ADMIN
Nicholas
Created on: 12 Jun 2024 10:47
Category: RadioGroup
Type: Bug Report
2
FocusAsync Not Working

The RadioGroup's FocusAsync() method does not work. To reproduce, run this example and press the button: https://docs.telerik.com/blazor-ui/components/radiogroup/overview#radiogroup-reference-and-methods

===

A possible workaround is to use JavaScript to focus the first or the selected <input> element:

@inject IJSRuntime js

<TelerikButton OnClick="@FocusRadioGroup">Focus RadioGroup</TelerikButton>

<TelerikRadioGroup Data="@RadioGroupData"
                   Class="my-radiogroup"
                   @bind-Value="@RadioGroupValue"
                   ValueField="@nameof(ListItem.Id)"
                   TextField="@nameof(ListItem.Text)">
</TelerikRadioGroup>

@* Move JavaScript code to a separate JS file in production *@
<script suppress-error="BL9992">function focusRadio(RadioGroupValue) {
        var mrg = RadioGroupValue == null ?
            document.querySelector(".my-radiogroup .k-radio-list-item input") :
            document.querySelector(`.my-radiogroup .k-radio-list-item input[value='${RadioGroupValue}']`);
        if (mrg) {
            mrg.focus()
        }
    }</script>

@code{
    private int? RadioGroupValue { get; set; }

    List<ListItem> RadioGroupData { get; set; } = new List<ListItem>() {
        new ListItem { Id = 1, Text = "Foo" },
        new ListItem { Id = 2, Text = "Bar" },
        new ListItem { Id = 3, Text = "Baz" }
    };

    private async Task FocusRadioGroup()
    {
        await Task.Delay(1);

        await js.InvokeVoidAsync("focusRadio", RadioGroupValue);
    }

    public class ListItem
    {
        public int Id { get; set; }
        public string Text { get; set; } = string.Empty;
    }
}

4 comments
ADMIN
Dimo
Posted on: 05 Sep 2024 15:07

Hello Alexander,

For any public item, an "Unplanned" status means that the item is gathering voted and awaiting prioritization. There is no determined fix time frame.

Regards,
Dimo
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.

Alexander
Posted on: 05 Sep 2024 15:02

Hello Dimo,

thanks for your reply and the workaround. Any idea when this bug will be fixed?

Regards,

Alex

ADMIN
Dimo
Posted on: 05 Sep 2024 14:58

@Alexander,

Yes, we are aware of this bug. The intended behavior is to focus the selected radio button, or the first one if there is no selection yet.

I added a JavaScript-based workaround in the original post.

Regards,
Dimo
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.

Alexander
Posted on: 05 Sep 2024 12:52

Hello everyone,

we just noticed this as well. Here is a REPL of the code from the example mentioned above: https://blazorrepl.telerik.com/QekZYflm50zUbOAt24

Telerik team: are you aware of this bug? Is this a bug? What is even supposed to happen anyway if a radio group is focused? The first radio button gets focused?