protonemedia / inertiajs-tables-laravel-query-builder

Inertia.js Tables for Laravel Query Builder
https://protone.media/en/blog/introducing-inertiajs-tables-a-datatables-like-package-for-laravel-query-builder
MIT License
438 stars 123 forks source link

no way to preserveScroll #43

Closed knobik closed 2 years ago

knobik commented 2 years ago

There is no way to set the "preserveScroll" property of $inertia.get() [queryBuilderData], each time i change a filter etc, the page scrolls to the top. preserveScroll should be default behavior.

this is resolved in PR #45 in the mean time i will use my own repo. Anyway awsome package!

pascalbaljet commented 2 years ago

Thanks for the PR! I think preserveScroll should be false when you navigate to the next or previous page, but I agree with the filters change. I'll take a look at it soon!

knobik commented 2 years ago

It realy depends, if i have a table on the bottom of the page, then i dont want the whole page to scroll. there should be a way to configure it somehow.

patrocle commented 2 years ago

Hi, for those who waits for this merge, make your own InteractsWithQueryBuilder : import InteractsWithQueryBuilder from '@/Components/DatatableTailwind/InteractsWithQueryBuilder';

<script>
import {InteractsWithQueryBuilder,Components} from '@protonemedia/inertiajs-tables-laravel-query-builder';

export default {
    mixins: [InteractsWithQueryBuilder],
    watch: {
        queryBuilderData: {
            deep: true,
            handler() {
                if (this.$inertia) {
                    const query = this.queryBuilderString;
                    this.$inertia.get(location.pathname + `?${query}`, {}, {
                        replace: true,
                        preserveState: true,
                        preserveScroll: true
                    });
                }
            },
        },
    },
};
</script>
pascalbaljet commented 2 years ago

Fixed in v2