Skip to content

BbDataGrid global search only triggers on blur or Enter instead of using the documented debounce #543

Description

@frabe1579

Tested version
BlazorBlueprint.Components 3.15.0
Description
According to the Data Grid documentation (https://blazorblueprintui.com/docs/components/data-grid), enabling ShowSearch should provide a debounced global search input. However, the search callback is only triggered when the input loses focus or when the user presses Enter.
Typing text and waiting for the debounce interval does not invoke the search or refresh an ItemsProvider. Clearing the input also does not reload the full dataset until Enter is pressed or the input loses focus.
This behavior is also reproducible on documentation DataGrid documentation section Global Search.

Minimal reproduction

<BbDataGrid TData="Account"
            ItemsProvider="LoadAccounts"
            ShowSearch="true"
            SearchDebounceMs="300">
    <Columns>
        <BbDataGridPropertyColumn Property="@(x => x.Name)"
                                   Filterable="true" />
    </Columns>
</BbDataGrid>
private async ValueTask<DataGridResult<Account>> LoadAccounts(DataGridRequest request)
{
    Console.WriteLine(request.SearchText);

    // Load data using request.SearchText
    ...
}

Steps to reproduce

  1. Create a BbDataGrid with ShowSearch="true".
  2. Use an ItemsProvider.
  3. Type a search term.
  4. Stop typing and wait longer than SearchDebounceMs.
  5. Observe that the provider is not called with the new search text.
  6. Press Enter or move focus away from the input.
  7. Observe that the search is then triggered.
    Expected behavior
    SearchTextChanged and/or ItemsProvider should be invoked automatically after the configured debounce interval, without requiring Enter or blur.
    Clearing the input should also trigger a debounced refresh with an empty or null search value.

Actual behavior
The search input behaves like an OnChange input:

  • no callback while typing;
  • no callback after the debounce interval;
  • callback only on blur or Enter.

Possible cause
BbDataGrid internally renders the search input approximately as:

<BbInput Value="@(_searchInputValue ?? SearchText)"
         ValueChanged="@HandleSearchInput"
         Placeholder="..." />

BbInput defaults to UpdateTiming.OnChange. The HandleSearchInput method then implements its own debounce using Task.Delay, but it never receives per-keystroke updates, so the debounce cannot start until blur or Enter.
The internal input may need to explicitly use:

<BbInput Value="@(_searchInputValue ?? SearchText)"
         ValueChanged="@HandleSearchInput"
         UpdateTiming="UpdateTiming.Immediate"
         ... />

This would allow HandleSearchInput to perform the documented debounce correctly.

Workaround currently used
Applications can hide the built-in search and provide their own debounced BbInput, then call the grid’s public RefreshDataAsync() method after the debounced value changes. This works, but it defeats the purpose of the documented ShowSearch and SearchDebounceMs API.

(written with help of AI)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions