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 Request] CommandPalette supports a loading state. #179

Closed
emojiiii opened this issue May 17, 2023 · 7 comments · Fixed by #221
Closed

[Feature Request] CommandPalette supports a loading state. #179

emojiiii opened this issue May 17, 2023 · 7 comments · Fixed by #221
Labels
enhancement New feature or request

Comments

@emojiiii
Copy link

Is your feature request related to a problem? Please describe.

Yes, the feature request is related to the problem of querying API results and needing to display a loading state while the results are being fetched.

Describe the solution you'd like

The solution I would like is for the CommandPalette component to have a loading state that can be displayed while the API results are being fetched. This would help improve the user experience by letting them know that the query is being processed and that they should wait for the results.

Describe alternatives you've considered

One alternative that could be considered is to not have a loading state and just let the user wait for the results without any indication of progress. However, this could lead to confusion and frustration for the user, especially if the query takes a long time.

Additional context

image
@emojiiii emojiiii added the enhancement New feature or request label May 17, 2023
Copy link
Member

Hello @emojiiii,

I know this doesn't solve your issue but I just added an example in the documentation on how to perform async search within the CommandPalette component with the search field: https://ui.nuxtlabs.com/navigation/command-palette#async-search

What about displaying a loading icon when one of the CommandPalette group search function loads?

@emojiiii
Copy link
Author

field: https://ui.nuxtlabs.com/navigation/command-palette#async-search

Thank you very much. I think this can serve as a temporary solution.

Copy link
Member

@emojiiii Just made a PR to support a loadingIcon in the command palette like on the Button and Input. This is also automatically handled when using a search function. Let me know what you think!

@emojiiii
Copy link
Author

Thank you very much for your PR. However, I believe that compared to searches like button and input, the command palette has a larger visible area, and the loading status is more prominent when placed in the center of the pane panel.

Copy link
Member

This would imply hiding all the existing results each time you type something.

@emojiiii
Copy link
Author

I think you are right, this could indeed lead to that issue. Maybe we can add an additional layer of mask + loading status on top of it.

By the way, could you please tell me how to set the debounce time? And how can I cancel the previous API request when making a new one?

Copy link
Member

You can use the debounce prop that defaults to 200. To cancel the previous API request, I've never tried myself but you might want to take a look at this issue unjs/ofetch#23 about AbortController when using $fetch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants