Task Description
Improvements for the Pagination component. There are various issues with the Pagination component due to the fact that internally it uses an uncontrolled Select in the select variant. This leads to unexpected behaviour when the initial props that are passed to the component change (e.g. because the total number of pages was retrieved asynchronously after the component was already rendered. To fix this we will use the Select in controlled mode and keep internal state in the Pagination component itself. This way it can by used like an uncontrolled or a controlled component. This will lead to less confusion for app developers.
Additionally add some extra features to the Pagination component: disabled state for the whole component, loading state
Bug fix: input field width should be dynamic in case of huge numbers
Sub-tasks
[x] add new prop disabled to disable whole component
[x] add new prop loading that shows loading state
[x] change internal Select to use value instead of defaultValue so that we use it in controlled mode
[x] add internal state (currentPage, pages)
[x] add useEffect for props to make it possible to update Pagination
[x] dynamic input field width
Fixes:
[x] Do not set default value of 1 to currentPage and totalPages. Instead keep them undefined. In all event handlers handle undefined for these. Ensure currentPage changes only happen if currentPage is not falsy.
[x] If currentPage is set prev button always decreases currentPage by 1 (1 is minimum), next button always increases currentPage by 1 (if totalPages is set, the following is true: `1 <= currentPage <= totalPages)
[x] Event handlers that change the value of currentPage should return the new value, otherwise undefined
Task Description Improvements for the Pagination component. There are various issues with the
Pagination
component due to the fact that internally it uses an uncontrolledSelect
in the select variant. This leads to unexpected behaviour when the initial props that are passed to the component change (e.g. because the total number of pages was retrieved asynchronously after the component was already rendered. To fix this we will use the Select in controlled mode and keep internal state in thePagination
component itself. This way it can by used like an uncontrolled or a controlled component. This will lead to less confusion for app developers.Additionally add some extra features to the Pagination component: disabled state for the whole component, loading state Bug fix: input field width should be dynamic in case of huge numbers
Sub-tasks
disabled
to disable whole componentloading
that shows loading statevalue
instead ofdefaultValue
so that we use it in controlled modeFixes:
1
to currentPage and totalPages. Instead keep them undefined. In all event handlers handle undefined for these. Ensure currentPage changes only happen if currentPage is not falsy.currentPage
is set prev button always decreases currentPage by 1 (1 is minimum), next button always increases currentPage by 1 (if totalPages is set, the following is true: `1 <= currentPage <= totalPages)