cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x] Push listing page state to URL query params

Open jacksleight opened this issue 1 year ago • 2 comments

This PR pushes the listing components parameters to the URL, so that you can bookmark, refresh and navigate back/forwards while maintaining the selected sort, filters, search, columns, page etc.

This is an opt-in feature of the listing mixin, since it might not make sense for all types of listing, especially when you have more than one on the same page (eg. Dashboard). To enable it set pushQuery to true.

I have enabled it for the main entry, term and user listings.

The additionalParameters are not pushed to the URL, since the listing mixin wont know what they are or how to handle them.

I asked ChatGPT for the utf8atob function, it seems to work fine but I have no idea if it's perfect.

Closes https://github.com/statamic/ideas/issues/93

jacksleight avatar Jan 26 '24 16:01 jacksleight

Ah yeah, will take a look.

jacksleight avatar Jan 26 '24 22:01 jacksleight

I've made the changes. Empty values are now filtered out from the parameters object.

I made the parameter map a computed property because I wasn't really sure where else to put it, but also that means people who are extending can easily override it to push other custom parameters to the URL as well. The additionalParameters are still only included in the backend request, they're not pushed to the URL.

jacksleight avatar Jan 30 '24 17:01 jacksleight