From d61a6f90fb5e02e9c8db2e15f2d49bb9db541dad Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 23 Nov 2021 21:41:46 +0100 Subject: [PATCH] chore: add console.log and fallbacks to 1 --- .../src/components/pagination/Pagination.js | 6 +---- .../pagination/PaginationInfinity.js | 24 +++++++++++++++++++ .../pagination/PaginationProvider.js | 9 +++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/dnb-eufemia/src/components/pagination/Pagination.js b/packages/dnb-eufemia/src/components/pagination/Pagination.js index 483686e30c0..8ec9bea1a85 100644 --- a/packages/dnb-eufemia/src/components/pagination/Pagination.js +++ b/packages/dnb-eufemia/src/components/pagination/Pagination.js @@ -96,11 +96,7 @@ const paginationPropTypes = { class: PropTypes.string, className: PropTypes.string, - children: PropTypes.oneOfType([ - // PropTypes.array, - PropTypes.node, - PropTypes.func, - ]), + children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), on_change: PropTypes.func, on_startup: PropTypes.func, diff --git a/packages/dnb-eufemia/src/components/pagination/PaginationInfinity.js b/packages/dnb-eufemia/src/components/pagination/PaginationInfinity.js index 587689747fa..8f3c61bfb9c 100644 --- a/packages/dnb-eufemia/src/components/pagination/PaginationInfinity.js +++ b/packages/dnb-eufemia/src/components/pagination/PaginationInfinity.js @@ -72,6 +72,11 @@ export default class InfinityScroller extends React.PureComponent { ) => { const { pageCount, endInfinity } = this.context.pagination + console.log('InfinityScroller: getNewContent', { + newPageNo, + pageCount, + }) + // if "page_count" is set do not load more than that value if (newPageNo > pageCount) { return endInfinity() @@ -200,6 +205,18 @@ export default class InfinityScroller extends React.PureComponent { indicator_element, } = this.context.pagination + console.log('InfinityScroller: render', { + // our states + lowerPage, + upperPage, + pageCount, + hasEndedInfinity, + parallelLoadCount, + + // our props + current_page, + }) + const Marker = () => ( 0)) { clearTimeout(this._startupTimeout) @@ -291,6 +310,11 @@ export default class InfinityScroller extends React.PureComponent { return null // stop here } + console.log( + 'InfinityScroller: useMarkerOnly', + this.context.pagination.useMarkerOnly + ) + if (this.context.pagination.useMarkerOnly) { return this.handleInfinityMarker() } diff --git a/packages/dnb-eufemia/src/components/pagination/PaginationProvider.js b/packages/dnb-eufemia/src/components/pagination/PaginationProvider.js index f51132932d1..10ce3b0da44 100644 --- a/packages/dnb-eufemia/src/components/pagination/PaginationProvider.js +++ b/packages/dnb-eufemia/src/components/pagination/PaginationProvider.js @@ -106,7 +106,7 @@ export default class PaginationProvider extends React.PureComponent { // only used by handleInfinityMarker if (props.useMarkerOnly) { if (typeof state.lowerPage === 'undefined') { - state.lowerPage = state.startupPage + state.lowerPage = state.startupPage || 1 } const cur = parseFloat(props.current_page) if (!isNaN(cur) && cur < state.lowerPage) { @@ -114,8 +114,11 @@ export default class PaginationProvider extends React.PureComponent { } if (typeof state.upperPage === 'undefined') { state.upperPage = - state.startupPage + parseFloat(props.startup_count) - 1 + state.startupPage + (parseFloat(props.startup_count) || 1) - 1 || + 1 } + console.log('InfinityScroller: lowerPage', state.lowerPage) + console.log('InfinityScroller: upperPage', state.upperPage) } // reset content, like the resetContent method @@ -288,6 +291,8 @@ export default class PaginationProvider extends React.PureComponent { } endInfinity = () => { + console.log('InfinityScroller: endInfinity') + this.setState( { hasEndedInfinity: true,