© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
Kenneth Sese

Select Field search not reloading options after clearing search

I have a select field that I'm searching on. It searches through an array of data. Searching works, but if you search, then backspace to clear the search, only the last search is appearing. I have to then add a space and to get all the options again. (See video) Am I doing something wrong? Thanks!

Select::make('item')
    ->searchable()
    ->preload()
    ->searchDebounce(200)
    ->options(fn () => static::getItems())
    ->getSearchResultsUsing(function (string $search) {
        return static::getItems($search);
    }),
Select::make('item')
    ->searchable()
    ->preload()
    ->searchDebounce(200)
    ->options(fn () => static::getItems())
    ->getSearchResultsUsing(function (string $search) {
        return static::getItems($search);
    }),


protected static function getItems(string $search = null)
{
    $items = [
        'foo',
        'bar',
    ];

    return collect($items)
        ->filter(function ($item) use ($search) {
            if (blank($search)) {
                return true;
            }
            
            return Str::contains($item, $search);
        })
        ->toArray();
}
protected static function getItems(string $search = null)
{
    $items = [
        'foo',
        'bar',
    ];

    return collect($items)
        ->filter(function ($item) use ($search) {
            if (blank($search)) {
                return true;
            }
            
            return Str::contains($item, $search);
        })
        ->toArray();
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

JavaScript Select Search Options
FilamentFFilament / ❓┊help
16mo ago
Testing select field options
FilamentFFilament / ❓┊help
3y ago
Searchable select field shows incorrect search results
FilamentFFilament / ❓┊help
2y ago
Search modified select field
FilamentFFilament / ❓┊help
9mo ago