Skip to content

Commit f0f46a3

Browse files
Fix pagination showing 2 buttons with 0 available pages (#142)
1 parent 5f01236 commit f0f46a3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/Examples/Pagination.example.purs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ docs = unit # make (createComponent "PaginationExample")
3737
, details = Just $ R.text "40 results"
3838
}
3939

40+
, example
41+
$ pagination defaults
42+
{ currentPage = self.state.currentPage
43+
, pages = 0
44+
, onChange = self.setState <<< flip _{ currentPage = _ }
45+
, details = Just $ R.text "0 results"
46+
}
47+
4048
, example
4149
$ pagination defaults
4250
{ currentPage = self.state.currentPage

src/Lumi/Components/Pagination.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pagination = makeStateless (createComponent "Pagination") render
3636
let
3737
boundedPage = clamp 0 (props.pages - 1) props.currentPage
3838
rangeMin = max 0 (boundedPage - (props.focusWindow / 2))
39-
rangeMax = min (props.pages - 1) (boundedPage + (props.focusWindow / 2))
39+
rangeMax = max 0 $ min (props.pages - 1) (boundedPage + (props.focusWindow / 2))
4040

4141
prevButton =
4242
keyed "prev" $ R.li_

0 commit comments

Comments
 (0)