improve table search -load with a delay

improve table search -load with a delay

1 vote

avatar

# Feature Request: Configurable debounce for `New-UDTable` search

## Summary

Add a configurable debounce interval to the global search box on `New-UDTable`, especially for dynamic tables that use `-LoadRows` (`-LoadData` alias).

For example, `-SearchDebounceMs 1000` would wait until the user has stopped typing for one second, then submit only the latest search value.

## Problem

When a user types a search term into a dynamic table, intermediate values such as `e`, `er`, `err`, `erro`, and `error` can each trigger the server-side load callback. This can create unnecessary requests and work while the user is still typing. It can be costly when the callback queries SQL or another remote data source, and it can also add avoidable PSU server and network work when filtering cached data.

The current `New-UDTable` documentation describes `-ShowSearch` and the search value passed to the dynamic load callback as `$EventData.Search`, but does not document a setting to control the delay.

## Proposed API

```powershell
New-UDTable `
-ShowSearch `
-SearchDebounceMs 1000 `
-LoadRows {
# Process the latest $EventData.Search value.
}
```

`-SearchDebounceMs` is a suggested parameter name. The default should preserve current behavior for existing tables. A value of `0` could disable the delay.

## Expected behavior

- Reset the timer whenever the user changes the search text.
- After the configured quiet period, invoke the dynamic load callback once with the latest search value.
- Do not submit obsolete intermediate search values after the timer resets.
- Apply the setting to global search only; sorting, paging, refresh, and column-filter actions should keep their current timing.
- Preserve current behavior when the parameter is omitted.
- Document the parameter and its behavior in the `New-UDTable` reference.

## Acceptance criteria

1. With a 1000 ms delay, typing `error` with less than one second between keystrokes invokes the dynamic load callback once with `error` after typing stops.
2. If the user pauses for at least the configured interval, the callback runs with the current search value.
3. Clearing the search produces the correct unfiltered result after the configured interval.
4. With the parameter omitted, existing applications keep their current search behavior.
5. Paging, sorting, refresh, and column filters are not delayed by the search setting.

## Context

In the jSourceAssistant Cases page, the table uses `-ShowSearch` with a `-LoadData` callback. The callback receives the search state and filters rows held in the PSU session. That specific callback does not query SQL for each keystroke; the case data is loaded separately. A configurable debounce would still reduce callback traffic for this table and help other dynamic tables whose load callbacks query SQL or remote services.

The current PowerShell Universal version was not recorded for this request.

## References

- [New-UDTable command reference](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udtable)
- [Table component guide](https://docs.devolutions.net/powershell-universal/apps/components/data-display/table)

All Comments (0)