fix: paginated list history headings were not rendering when there was only one unique heading (#3496)

* fix: paginated list history headings were not rendering when there was only one unique heading

* minor bug
This commit is contained in:
Nan Yu
2022-05-04 21:08:50 -07:00
committed by GitHub
parent eeb8008927
commit 9117b7479f
2 changed files with 9 additions and 14 deletions

View File

@@ -119,7 +119,7 @@ class PaginatedList<T extends PaginatedItem> extends React.Component<Props<T>> {
// of lazy rendering then show another page.
const leftToRender = (this.props.items?.length ?? 0) - this.renderCount;
if (leftToRender > 1) {
if (leftToRender > 0) {
this.renderCount += DEFAULT_PAGINATION_LIMIT;
}
@@ -140,7 +140,6 @@ class PaginatedList<T extends PaginatedItem> extends React.Component<Props<T>> {
renderHeading,
onEscape,
} = this.props;
let previousHeading = "";
const showLoading =
this.isFetching &&
@@ -168,8 +167,9 @@ class PaginatedList<T extends PaginatedItem> extends React.Component<Props<T>> {
aria-label={this.props["aria-label"]}
onEscape={onEscape}
>
{(composite: CompositeStateReturn) =>
items.slice(0, this.renderCount).map((item, index) => {
{(composite: CompositeStateReturn) => {
let previousHeading = "";
return items.slice(0, this.renderCount).map((item, index) => {
const children = this.props.renderItem(item, index, composite);
// If there is no renderHeading method passed then no date
@@ -202,8 +202,8 @@ class PaginatedList<T extends PaginatedItem> extends React.Component<Props<T>> {
}
return children;
})
}
});
}}
</ArrowKeyNavigation>
{this.allowLoadMore && (
<Waypoint key={this.renderCount} onEnter={this.loadMoreResults} />