cms
cms copied to clipboard
The select look ahead on a Filter that use a Dictionary field doesn't work
Bug description
I made a filter using a dictionary field, and when I try to find a value to use, the "search" stops.
Please see the video and the code below.
How to reproduce
I made a filter that is the title of entries:
<?php
namespace App\Scopes;
use Statamic\Facades\Entry;
use Statamic\Query\Scopes\Filter;
class EventTitle extends Filter
{
public static function title()
{
return __('Title');
}
public function fieldItems()
{
return [
'slug' => [
'type' => 'dictionary',
'dictionary' => 'event_title',
'placeholder' => __('Title'),
'max_items' => 1,
],
];
}
/**
* @param \Statamic\Query\Builder $query
* @param array $values
* @return void
*/
public function apply($query, $values)
{
}
public function badge($values)
{
if ($slug = $values['slug']) {
return Entry::query()
->where('collection', 'events')
->where('slug', $slug)
->first();
}
return __('Title');
}
public function visibleTo($key)
{
return $key === 'entries' && $this->context['collection'] == 'events';
}
}
Dictionary:
<?php
namespace App\Dictionaries;
use Statamic\Dictionaries\BasicDictionary;
use Statamic\Facades\Entry;
class EventTitle extends BasicDictionary
{
protected function getItems(): array
{
return Entry::whereCollection('events')
->pluck('title', 'slug')
->map(fn ($title, $slug) => ['label' => $title, 'value' => $slug])
->values()
->all();
}
}
Video that shows issue: https://share.cleanshot.com/TF98Wgw8.
You can see that I'm trying to select one that has Cold Case, but after I type the second c I don't get any results.
Logs
No response
Environment
Environment
Application Name: Zakat Foundation of America
Laravel Version: 11.23.5
PHP Version: 8.3.11
Composer Version: 2.7.7
Environment: local
Debug Mode: OFF
URL: zakat.test
Maintenance Mode: OFF
Timezone: America/Los_Angeles
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: null
Cache: file
Database: mysql
Logs: stack / daily
Mail: smtp
Queue: redis
Session: file
Livewire
Livewire: v3.5.6
Statamic
Addons: 13
Sites: 4 (zakat.org (EN), zakat.org (AR), zfinstitute.com (ZFI), zakat.org (TR))
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.25.0 PRO
Statamic Addons
aryehraber/statamic-captcha: 1.13.0
edalzell/forma: 3.0.1
jacksleight/statamic-bard-mutator: 2.3.1
jacksleight/statamic-distill: 0.8.0
jonassiewertsen/statamic-livewire: 3.8.0
statamic-rad-pack/runway: 7.8.0
statamic/seo-pro: 6.1.2
transformstudios/events: 5.4.3
transformstudios/front: 3.0.1
transformstudios/github: dev-main
transformstudios/neon: dev-main
transformstudios/review: 5.0
transformstudios/simple: 5.4.4
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
It probably has to do with how we're handling search here...
https://github.com/statamic/cms/blob/be249c2088c4f23b7df7cf0efe09c2c1d37e8673/src/Dictionaries/BasicDictionary.php#L51-L66
It musn't play well with spaces.