woylie / flop_phoenix

Components for pagination, sortable tables and filter forms using Phoenix, Ecto and Flop
MIT License
354 stars 37 forks source link

[Bug] Get Page Link Range incorrect when hitting the maximum #322

Closed dbsimmons64 closed 4 months ago

dbsimmons64 commented 4 months ago

Summary

I believe the calculation for get page link range is incorrect.

Steps to reproduce

  1. Use the Flop.Phoenix.pagination component with {:ellipsis, 3}
  2. Select the last page, in my case this was 20
  3. Pagination component dispaly 18, 19, 20
  4. Select 18 and page 18 is display but Pagination component still display 18,19,20 meaning you cannot select page 17.

Expected behaviour

I would expect that when I select page 18 I'd see 17,18,19.

Actual behaviour

Unable to select page 17 from pagination component.

Elixir/Erlang version

Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]

Elixir 1.15.4 (compiled with Erlang/OTP 26)

Flop and Ecto versions

Additional context

I believe the get_page_link_range function is incorrect:

     current_page + additional >= total_pages ->

should be:

      current_page + additional > total_pages ->
woylie commented 4 months ago

Thanks for opening the issue, this should be fixed on main.

dbsimmons64 commented 4 months ago

Great stuff - thanks for creating a fantastic library.