There is no way to show hints in the RadzenAutoComplete when the search text is empty #690

Closed
opened 2026-01-29 17:41:38 +00:00 by claunia · 2 comments
Owner

Originally created by @frotewaus on GitHub (Jan 5, 2023).

RadzenAutoComplete provides a way to decide when the hints should be displayed, depending on the length of the input text. This is controlled by the MinLength parameter.

Unfortunately, when the MinLength is set to 0, the code does not display hints when the search text is of length 0 (when it is empty).
The hints do not display when the input is focused, nor do they display when entering some text and then removing it.

Reproduction Steps

  1. Create an example Blazor project
  2. Follow the steps from https://blazor.radzen.com/get-started to set up Radzen Blazor in the project
  3. Replace the Index.razor page with the following razor:
@page "/"

<Radzen.Blazor.RadzenAutoComplete
MinLength="0"
Data="@countries" />

@code {
    private List<string> countries = new List<string>()
    {
        "Austria",
        "Belgium",
        "Croatia",
        "Cyprus",
        "Czech Republic",
        "Denmark",
        "Estonia",
        "Finland",
        "France",
        "Germany",
        "Greece",
        "Hungary",
        "Iceland",
        "Ireland",
        "Italy",
        "Latvia",
        "Lithuania",
        "Netherlands",
        "Norway",
        "Poland",
        "Portugal",
        "Romania",
        "Slovakia",
        "Slovenia",
        "Spain",
        "Sweden",
    };
}
  1. When focusing on the input, nothing happens.
  2. When adding some text and later removing it, the popup can be seen but is empty

Expected behavior
Both in (4) and (5), I would expect the full countries list to be displayed


I have taken the liberty to take a look at the codebase and it seems that the assumption that the autocomplete only works when search text is not empty is hardcoded in several places:

  1. In razor: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenAutoComplete.razor#L31
    This condition does not really feel needed and it exposes fields searchText and customSearchText in razor that otherwise are internal to the logic of retrieving hints.
  2. In cs: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenAutoComplete.razor.cs#L156
  3. Additionally, the code that performs the hint retrieving is not prepared for an empty search text. The following dynamic query will fail when the search text is empty: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenAutoComplete.razor.cs#L174
Originally created by @frotewaus on GitHub (Jan 5, 2023). RadzenAutoComplete provides a way to decide when the hints should be displayed, depending on the length of the input text. This is controlled by the **MinLength** parameter. Unfortunately, when the MinLength is set to 0, the code does not display hints when the search text is of length 0 (when it is empty). The hints do not display when the input is focused, nor do they display when entering some text and then removing it. **Reproduction Steps** 1. Create an example Blazor project 2. Follow the steps from https://blazor.radzen.com/get-started to set up Radzen Blazor in the project 3. Replace the Index.razor page with the following razor: ``` @page "/" <Radzen.Blazor.RadzenAutoComplete MinLength="0" Data="@countries" /> @code { private List<string> countries = new List<string>() { "Austria", "Belgium", "Croatia", "Cyprus", "Czech Republic", "Denmark", "Estonia", "Finland", "France", "Germany", "Greece", "Hungary", "Iceland", "Ireland", "Italy", "Latvia", "Lithuania", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Sweden", }; } ``` 4. When focusing on the input, nothing happens. 5. When adding some text and later removing it, the popup can be seen but is empty **Expected behavior** Both in (4) and (5), I would expect the full countries list to be displayed --- I have taken the liberty to take a look at the codebase and it seems that the assumption that the autocomplete only works when search text is not empty is hardcoded in several places: 1. In razor: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenAutoComplete.razor#L31 This condition does not really feel needed and it exposes fields searchText and customSearchText in razor that otherwise are internal to the logic of retrieving hints. 2. In cs: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenAutoComplete.razor.cs#L156 3. Additionally, the code that performs the hint retrieving is not prepared for an empty search text. The following dynamic query will fail when the search text is empty: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenAutoComplete.razor.cs#L174
Author
Owner

@enchev commented on GitHub (Jan 10, 2023):

Hey @frotewaus,

This is how RadzenAutoComplete is designed to work - will list only suggestions based on input. If you just need to pick some entry with filtering you can consider using RadzenDropDown component.

@enchev commented on GitHub (Jan 10, 2023): Hey @frotewaus, This is how RadzenAutoComplete is designed to work - will list only suggestions based on input. If you just need to pick some entry with filtering you can consider using RadzenDropDown component.
Author
Owner

@frotewaus commented on GitHub (Jan 11, 2023):

@enchev from my understanding, RadzenDropDown only allows entering values that are in the list, whereas AutoComplete allows other free form entries, this is not the presented use case.
What I am describing is a genuine business use case to have a texbox that provides hints based on provided input, that would also include an empty input.

@frotewaus commented on GitHub (Jan 11, 2023): @enchev from my understanding, RadzenDropDown only allows entering values that are in the list, whereas AutoComplete allows other free form entries, this is not the presented use case. What I am describing is a genuine business use case to have a texbox that provides hints based on provided input, that would also include an empty input.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#690