sveltejs / examples

A collection of Svelte(Kit) examples
MIT License
34 stars 5 forks source link

SvelteKit Search and Filter Page Example #11

Open karimfromjordan opened 1 year ago

karimfromjordan commented 1 year ago

This surprisingly came up several times this week on Discord — a page that should fetch, filter and search some data through a <form> and search params in load. My idea was a simple products, words, fruits etc. page which:

geoffrich commented 1 year ago

It doesn't have all the details, but I took some notes on my solution for this: https://geoffrich.net/posts/marvel-filter-state/#heading-automatically-submitting-the-form-with-requestsubmit. It's for a Marvel comics search form that has both text inputs (that I debounce) and checkboxes.

It doesn't take into account the new data-sveltekit-replacestate and data-sveltekit-keepfocus link options, which weren't available when I wrote this, so I had to write a custom submit handler instead.

karimfromjordan commented 1 year ago

Oh~ interesting. Yeah this is pretty much what I had in mind. I recently worked on a dictionary site for a client where I also wrestled with some of the points you mention in the blog post. Thanks for the link. Will probably be a good idea then to put all of this into a working example.