-
Notifications
You must be signed in to change notification settings - Fork 179
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
Fetch all authors from REST API and make dropdown scrollable #813
Conversation
Size Change: +330 B (0%) Total Size: 511 kB
ℹ️ View Unchanged
|
I think the larger issue here is, that only 10 users are loaded from the db. All db users should be loaded and selectable in the dropdown. |
I think the issue here is that, the REST API only returns 10 by default. The api maxes out at 100. As to get all users, we would have to pagination through all users. |
Now we have loading from multiple api request, it take a look time for the api requests to load. Should we check if |
I think |
There is already a check, but I am seeing an empty dropdown for a bit. |
Okay. Then we may need that to dropdown. |
Should be check if see if not not null users and length is more than 0? |
Yes, basically we have checking point for |
hmm... that maybe doesn't make sense. It would be good to add length check after |
@spacedmonkey basically if we add that beside users check in then the author line with dropdown will appear after all the users loaded. And if we add that to dropdown then the author line shows and the correct value set for dropdown after users fully loaded. What do you think about this? Which would be the expected behavior for this? |
The user dropdown loads after in gutenberg. The alternative here to a dropdown that doesn't work at all. The best UX would be only load the users when the dropdown is clicked, as they may never use the dropdown at all. But that is more work. CC @pbakaus @swissspidy What do you think? Hide the author dropdown until all users have loaded or user something and have a possibly none functioning dropdown for a while. |
I would definitely recommend loading it async (not on demand when clicking the dropdown, but also not in the critical path of the editor). So:
Relatedly, bonus points for loading the entire JS for this async, and not have a single bundle for everything. |
@ndev1991 Did you try passing See this comment. WordPress/gutenberg#21212 (comment) |
@spacedmonkey yes. It's same with 100. Returns 100 users at a time when using -1 |
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.
LGTM
Just to clarify: passing |
@swissspidy Yes, passing |
@ndev1991 Please test this again. The following code automatically resulted in multiple HTTP requests being made, loading all users on the site: const getAllUsers = useCallback(() => {
return apiFetch({ path: addQueryArgs(users, { per_page: '-1' })});
}, [users]); |
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.
In my testing this just worked for me:
const getAllUsers = useCallback(() => {
return apiFetch({ path: addQueryArgs(users, { per_page: '-1' })});
}, [users]);
Because api-fetch automatically handles this for us.
@swissspidy yes it's working. I didn't see it makes multiple http request to fetch all the users. |
Issue #756
Add scrollbar inside dropdown and set the max-height.