field value disapear during my slug generation

This is my field code: TextInput::make('name') ->required() ->label('Nom de la chambre') ->live(onBlur: true) ->afterStateUpdated(fn(?string $state, Set $set) => $set('slug', SlugService::createSlug(Lodging::class, 'slug', $state ?? '', ['unique' => true])))
Like the video show, during the time during the slug is generated, if the user continue to fill the form, it will remove all. Not a good experience for the user. How can I ovoid this ?
7 Replies
Frédéric
FrédéricOP6mo ago
Hello ! No one ?
Frédéric
FrédéricOP6mo ago
Thx for the answer but not the best solution. I can't just specify the input to updat and not update the other ?
toeknee
toeknee6mo ago
You have to disable the inputs based on loading. Most of the time it's quick enough to not notice / delay of the changes
Frédéric
FrédéricOP6mo ago
Thank's for your answer. 😄 Yes, maybe it's because it's on myu local ... ^^^' Thank's for the answer but I don't understand how that can help me 😄
micraux
micraux6mo ago
You use ->live(onBlur: true) which means that your slug field is populated only when you leave your name field. I guess you choose this instead of just ->live() to avoid many requests occurring every time a simple character is typed. But it appears to be too slow: so try and use debouncing (my link) in order to find a "in-between" solution.
Want results from more Discord servers?
Add your server