Skip to content
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

Feature: Improve select components #642

Merged
merged 1 commit into from
Aug 23, 2022

Conversation

JeanPaiva
Copy link
Contributor

@JeanPaiva JeanPaiva commented Jul 25, 2022

This PR changes how the posts selects works.

  • Reduce the amount of first loaded posts from 100 to 10
  • Does an extra request to fetch the selected values
  • Upon search will fetch posts with the search value and persist the previous results
  • Order posts by "id"

This affects Query loop "Parent", "Exclude Parent", "Include posts", "Exclude posts" and Dynamic data "Select source post".

There's the possibility to add pagination upon scroll, but we are limited by the API. We can, for example, increase the page number on each scroll fetching more posts, but the API does not support to make request with a number larger the the actual "page" count, so its required to us to know before hand how many pages the request has.

Currently, the only way to know the number of total pages on request is checking the "Header" of the request, but the core hooks seems to not have a way for us to use that information. Using our own implementation of fetching posts was also an option and could solve the pagination problem, but would require us to implement state caching so we don't re-fetch same requests many times thus requiring much more work than expected.

After testing, if everything is working fine as supposed to we must replicate this changes to all Terms selects.

@JeanPaiva JeanPaiva added the feature Features, refactoring, enhancements, improvements label Jul 25, 2022
@JeanPaiva JeanPaiva force-pushed the improve-select-components branch from 35829d6 to ef3ab4a Compare July 27, 2022 16:24
@JeanPaiva JeanPaiva requested a review from tomusborne July 27, 2022 16:32
@JeanPaiva JeanPaiva self-assigned this Jul 27, 2022
@JeanPaiva JeanPaiva added this to the 1.5.5 milestone Jul 27, 2022
@JeanPaiva JeanPaiva linked an issue Jul 27, 2022 that may be closed by this pull request
@tomusborne
Copy link
Owner

@JeanPaiva Could we do a "Load More" button at the bottom of the list? I assume if we click the button and no results are found we can hide it?

@JeanPaiva
Copy link
Contributor Author

@tomusborne we can have the button or even just load when user gets to the end of the list. The problem is requesting not existing page number, for example, https://example.com/wp-json/wp/v2/posts?page=2 if there's no page two the request will generate an console log error and using core hooks we can't even identify that to stop doing more requests.

@JeanPaiva JeanPaiva changed the base branch from master to release/1.5.5 August 8, 2022 13:57
@tomusborne
Copy link
Owner

And there's no way to catch the error and do something with it?

I think this should be targeted for release/1.6.0 so we have more time to test/improve it if possible.

@JeanPaiva JeanPaiva changed the base branch from release/1.5.5 to release/1.6.0 August 9, 2022 14:56
@JeanPaiva JeanPaiva modified the milestones: 1.5.5, 1.6.0 Aug 9, 2022
@JeanPaiva JeanPaiva merged commit 14f8246 into release/1.6.0 Aug 23, 2022
@JeanPaiva JeanPaiva deleted the improve-select-components branch August 23, 2022 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features, refactoring, enhancements, improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query Loop Parameter Select Component - REST API request fewer posts.
2 participants