Immediate Livewire update on table load

I've noticed that if I have a table with a dropdown filter, there is an immediate livewire update call on page load. Here is an example of a filter that is the 'culprit'
SelectFilter::make('priority')
->multiple()
->searchable(false)
->options(IssuePriority::options()) // This is not a model, it's an enum so there's no db call
->label(__('Priority')),
SelectFilter::make('priority')
->multiple()
->searchable(false)
->options(IssuePriority::options()) // This is not a model, it's an enum so there's no db call
->label(__('Priority')),
Removing this filter gets rid of the 2nd ajax call. The weird thing is that I have another SelectFilter on the same page
SelectFilter::make('category_id')
->searchable()
->options(fn (): array => Category::pluck('name', 'id')->toArray())
->label(__('Category')),
SelectFilter::make('category_id')
->searchable()
->options(fn (): array => Category::pluck('name', 'id')->toArray())
->label(__('Category')),
and this does not generate a 2nd call. Is this normal? Am I doing something wrong?
No description
3 Replies
Saade
Saade9mo ago
normal
ChesterS
ChesterS9mo ago
Haha thanks but could you elaborate a bit? Do you know why it happens? Any way to prevent it?
JohnPrice
JohnPrice6mo ago
Hello, I'm reopening the subject. I'm also wondering about this because it seems that this behavior also occurs on forms, and I have the impression that it changes the state of certain components. I've created a custom field that extends "TextInput", in which I have a method "canAccess" method that takes an array of rights as a parameter. If my array contains the "statePath" of the current field, then I proceed to disable it. Accessing my "Edit page" the behavior applies well, but once the "update" request is set to status 200, the field returns to default. How can I prevent this?
No description