What happens when :prev page request is used but there is no previous page?
Need help understanding how keyset pagination works. Here are the steps I took.
1. 'search-change' handle_event does the initial search properly. The query output is saved in a variable called page.
2. When the 'prev'' button is clicked triggering 'prev-page' handler, (as expected) nothing happens.
3. When the "next" button is clicked triggering 'next-page' handler, nothing happens. I expected it to return the iintial search results again, or the set after that.
`
Do I need to do something to prevent :prev page request where there is no previous page? If so, how do I do that?
I saw this example, but thought page request is a simpler way to do the same.
4 Replies
🤔 interesting...I think ideally a test case in our pagination tests illustrating this behavior would be the most helpful
Thanks! I will take a look.
This test fails. It's probably my expectation that's faulty. What am I missing? BTW, in a similar test, I noticed Offset pagination returns %{name: "4"} for :prev. which is what I would have liked.
This is the output when inspecting the result of :prev.
So I think the limitation is effectively that, unlikely offset pagination, we don't actually know here if there is a previous page or not
its one of the trade-offs of keyset based pagination
we can technically fake it for just this one exact instance where you have a page w/ no
before
and you ask for the prev
page
but that won't solve the problem everywhere
because if you went forward one page, back one page, then you'd have a before
.
okay, I have an idea
I'll change the pagination code where if the next page is empty, we'll just return the previous page
okay, just pushed some changes to ash main, lets see how you like itThanks! Let me try it and report back.
It's working beautifully. Thank you!