-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix getEntityRecordsTotalPages
when per_page
is not provided
#59983
Fix getEntityRecordsTotalPages
when per_page
is not provided
#59983
Conversation
…relies on the defaults from REST API
Size Change: +33 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Nik!
The changes test really well for me:
- The
useEntityRecords
hook no longer triggers the warning. - The list data views work as before.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
…relies on the defaults from REST API (WordPress#59983) Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
What?
There is a bug reported by @Mamaduka where
getEntityRecordsTotalPages
can returnNaN
if the query doesn't provideper_page
relies on the defaults from REST API.How?
If the
per_page
argument is not provided, we can fallback to the header of the response, since it should update properly with other changes of the query. We should still derive the result if theper_page
is provided, because it's not part of the stable key, where we keep the information in state.Testing Instructions
per_page
argument is provided. You can test this easily in pages list(DataViews) and update therows per page
.per_page
and observe thatgetEntityRecordsTotalPages
returns the proper result.