@undeportedmexican okay, I'll share more then, thanks for your time.
So the first issue is that my Dropdown vue components are taking an object as their model. Meaning that the form.contact_type is an object. This results in a weird query string in the URL, so I am changing the params to be passed to Inertia like this:
let params = {
search: this.filter.search,
contact_type: this.filter.contact_type.id,
}
Inertia.get('/contacts', this.filter, {
preserveState : true,
replace : true,
preserveScroll: true,
})
I was also removing the empty properties from the params object, since otherwise it always loads with the full query string with empty properties: page?search=contact_type=
The second issue is that
watch: {
handler: {
'this.filter': _.throttle(function() {
[...]
}, 400)
},
deep: true,
}
Fires on each load. At times with some attempts, I manage to stop that, not really sure how since I'm basically always setting the filters to whatever comes from Inertia's props, so it triggers the watcher (which doesn't happen for the search, but for the dropdowns, it happens.
When this happens it also breaks the pagination since on pagination it sets the filters again triggering "filtering" and going back to page 1.
I'm setting them like this:
props: {
filters: Object,
},
data() {
return {
filter: {
search: this.filters.search,
contact_type: this.filters.contact_type;
}
}
},
This is how I return the values from the controller:
return Inertia::render('Contacts/List', [
// irrelevant data
'search' => $request->search ?? '',
'filters' => [
'contact_type' => $request->contact_type ? ContactType::find($request->contact_type)->only(['id', 'name']) : '',
'membership_type' => $request->membership_type ? MembershipType::find($request->membership_type)->only(['id', 'name']) : '',
'status' => $request->status ? Contact::getStatusesByName($request->status) : '',
]
]);
That's quite messy as well. There are a shitton of small problems that kind of seem that they require a lot of backend and frontend acrobatics and messy code to match up.
Either this or I'm doing something fundamentally wrong (like I was when I was first setting the properties in a created hook rather than the data property) which would be the ideal case.
Additionally, when I got it to kind of work with some minor bugs, my Dropdowns are using HeadlessUI from TailwindUI, the Listbox option there didn't catch the active property once Inertia is brought in, even though I can see that the model and the selected property are absolutely the same.