From 350524114a465537a32c54f435866bfd777e5d9b Mon Sep 17 00:00:00 2001 From: Dan Peterson Date: Fri, 17 Dec 2021 15:28:11 -0600 Subject: [PATCH] Fix the view more/less functionality by properly reporting the total number of claims (#530) --- ui/component/claimList/view.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/component/claimList/view.jsx b/ui/component/claimList/view.jsx index 4d9476b1f..af0d30764 100644 --- a/ui/component/claimList/view.jsx +++ b/ui/component/claimList/view.jsx @@ -91,13 +91,16 @@ export default function ClaimList(props: Props) { let tileUris = (prefixUris || []).concat(uris || []); tileUris = tileUris.filter((uri) => !excludeUris.includes(uri)); + + const totalLength = tileUris.length; + if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender); let sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || []; React.useEffect(() => { - if (typeof loadedCallback === 'function') loadedCallback(tileUris.length || 0); - }, [tileUris.length]); // eslint-disable-line react-hooks/exhaustive-deps + if (typeof loadedCallback === 'function') loadedCallback(totalLength); + }, [totalLength]); // eslint-disable-line react-hooks/exhaustive-deps const noResultMsg = searchInLanguage ? __('No results. Contents may be hidden by the Language filter.')