Pass a cleared query string as well.
Query String won't clear when empty data object
I've done this on the past and I don't remember ever struggling with this, but maybe I did it different.
I have my regular index controller, returning an inertia view, everything wotks perfect.
My issue comes when I add filters. I'm using a watcher on a reactive filters object to trigger a page reload, where my controller will catch it and filter the data accordingly.
Everything works fine, except when I clear the filter ( a text input to make a name search ). When I clear that input, the query string remains with the last state it had, it never clears. Even if I send an empty data object in the Inertia router visit options.
Is this a bug? Am i doing something wrong?
Here's the watcher I'm using:
const filters = reactive(props.queryFilters);
watch(
filters,
debounce(() => {
let options = {};
let pickedFilters = pickBy(filters);
if (Object.keys(pickedFilters).length > 0){
options.data = pickedFilters;
}
router.reload(options);
}, 200)
);
Please or to participate in this conversation.