F
Filament14mo ago
Remi

live fields updating other field lags and created mistakes

I have a "name" field which is reactive and on updating this field, the slug field is updated to a slugified version of this field. But since v3, there appears to be a lag on updating, and when you type fast, letters get lost and the words get messed up. the code:
Forms\Components\TextInput::make('name')
->live()
->required()
->string()
->maxLength(250)
->afterStateUpdated(function ($state, Forms\Set $set) {
$slug = Str::slug($state);
$set('slug', '/' . $slug);
}),

Forms\Components\TextInput::make('slug')
->required(),
Forms\Components\TextInput::make('name')
->live()
->required()
->string()
->maxLength(250)
->afterStateUpdated(function ($state, Forms\Set $set) {
$slug = Str::slug($state);
$set('slug', '/' . $slug);
}),

Forms\Components\TextInput::make('slug')
->required(),
attached is a video of the error. Any ideas?
3 Replies
Vp
Vp14mo ago
Try ->live(onBlur: true).. this will update the slug field after you move away from title input
Remi
RemiOP14mo ago
Yeah, that sort of works, but it's not really what i was hoping for. Still hoping for a live updating option
Want results from more Discord servers?
Add your server