Skip to content

Commit

Permalink
Fix: Update button position when number of rows per page is large (op…
Browse files Browse the repository at this point in the history
…ensearch-project#3797)

* Fix: Update button position when number of rows per page is large
* Update CHANGELOG.md

Signed-off-by: Sirazh Gabdullin <[email protected]>

---------

Signed-off-by: Sirazh Gabdullin <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
  • Loading branch information
curq and joshuarrrr authored Apr 14, 2023
1 parent 685c911 commit 01c5a92
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Clean up and rebuild `@osd/pm` ([#3570](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3570))
- [Vega] Add Filter custom label for opensearchDashboardsAddFilter ([#3640](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3640))
- [Timeline] Fix y-axis label color in dark mode ([#3698](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3698))
- [Table Visualization] Fix table rendering empty unused space ([#3797](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3797))
- [Table Visualization] Fix data table not adjusting height on the initial load ([#3816](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3816))
- Cleanup unused url ([#3847](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3847))

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/vis_type_table/public/utils/use_pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TableVisConfig } from '../types';
export const usePagination = (visConfig: TableVisConfig, nRow: number) => {
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: visConfig.perPage || 10,
pageSize: Math.min(visConfig.perPage || 10, nRow),
});
const onChangeItemsPerPage = useCallback(
(pageSize) => setPagination((p) => ({ ...p, pageSize, pageIndex: 0 })),
Expand All @@ -20,7 +20,7 @@ export const usePagination = (visConfig: TableVisConfig, nRow: number) => {
]);

useEffect(() => {
const perPage = visConfig.perPage || 10;
const perPage = Math.min(visConfig.perPage || 10, nRow);
const maxiPageIndex = Math.ceil(nRow / perPage) - 1;
setPagination((p) => ({
pageIndex: p.pageIndex > maxiPageIndex ? maxiPageIndex : p.pageIndex,
Expand Down

0 comments on commit 01c5a92

Please sign in to comment.