Replies: 2 comments 1 reply
-
The When you go to the next page, the end cursor (derived from the last row) becomes the The
In case the current user deletes an item from the list, you can handle deletions by:
In case an item is deleted without the doing of the current user, you'll have to live with the implications above, unless you want to put in the effort of publishing deletions on Phoenix PubSub and subscribing the LiveView to those events. |
Beta Was this translation helpful? Give feedback.
-
This has been resolved in a PR, and Ive got it fixed in production. I appreciate your help! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
We're using cursor-based pagination for large tables. Each page shows 3 results and each row has a button that allows the user to delete the row.
In the situation where a row has been deleted, and it was the only row on the last page, the pagination fails.
When the last page with the single row is requested and the single item is present, this is what the meta-field looks like:
The
after
cursor contains thedate_due
andid
of the last item on the previous page, which makes sense.The
start_cursor
andend_cursor
contain theid
anddate_due
of the only item on the last page.When a user now deletes this item, on the last page and I request the new page in the controller, I get zero results back because the only after the cursor has been deleted, and because there are no items, there is no
start_cursor
orend_cursor
.This causes the
Flop.Phoenix.cursor_pagination
function to fail with the below error.I'm wondering why, because if you know the
after
cursor, then it should be possible to get the 3 values right before theafter
cursor too, right?Any help is greatly appreciated.
I made a small MWE based on the documentation with
Pet
s. You can find it here: https://github.com/m1dnight/flop_bug/blob/pagination_mwe/.iex.exsThe exampl shows two pages; one page with 2 two pets (Bunny and Cat), and the second page with one pet, Dog.
If you delete the last pet, but you still have a cursor from the first page to the second page that page will load, but show 0 pets. If you then try to get the previous cursor from that page it will fail with the following error:
Beta Was this translation helpful? Give feedback.
All reactions