Issue when working with searchable method in Select component

Please make sure you see the video. The issue is when i work with searchable method in Select component it shows a random number sometimes 8 and sometimes 21 , but when i remove searchable method it just works fine Here is the filament code:
Select::make('theme_id')
->prefixIcon('heroicon-o-tag')
->label('Themes')
->options(Category::parentCategories()->pluck('name', 'id'))
->searchable()
->live(),

Select::make('category_id')
->required()
->searchable()
->prefixIcon('heroicon-o-rectangle-stack')
->label('Categories')
->options(function (Get $get) {
return Category::childCategories($get('theme_id'))->pluck('name', 'id');
})
Select::make('theme_id')
->prefixIcon('heroicon-o-tag')
->label('Themes')
->options(Category::parentCategories()->pluck('name', 'id'))
->searchable()
->live(),

Select::make('category_id')
->required()
->searchable()
->prefixIcon('heroicon-o-rectangle-stack')
->label('Categories')
->options(function (Get $get) {
return Category::childCategories($get('theme_id'))->pluck('name', 'id');
})
Here is the code for the childCategories scope:
public function scopeChildCategories($query, int $theme_id = null)
{
return $theme_id ? $query->where('parent_id', $theme_id) : $query->whereNotNull('parent_id');
}
public function scopeChildCategories($query, int $theme_id = null)
{
return $theme_id ? $query->where('parent_id', $theme_id) : $query->whereNotNull('parent_id');
}
2 Replies
DrByte
DrByte6mo ago
I'm sure there are query-related things to explore within Filament code, which may give clues, but I'd probably first find myself using dd() inside the options() closure to determine what's coming back in those cases. And then I'd probably trace back a layer deeper and dump out the db query that's pulling the data, to know why it's doing what you're seeing. The Laravel DebugBar is often what I first look at to inspect such queries. But I sometimes also just do something to the parameters I'm passing to the query that will break it, so that Ignition's error page will be shown, since it will show the whole broken query, but then I can use that query to see more of what's going on behind the scenes ... maybe even run it myself directly on the db. Since the searchable() does a lot of generation of subselects from relations, I find sometimes it's harder to follow the bouncing ball by code-diving until I've figured out what might be awry with the generated query. Once I know that part it's easier to dig through core code for answers.
Nikitha
Nikitha5mo ago
The issue is when i work with searchable method in Select component it shows a random text i.e arrow down in my option when tabbing to the searchable select component, but when i remove searchable method it just works fine. How can i solve this issue?