AutoComplete: New Feature - Loading Indicator & CancellationToken#3096
AutoComplete: New Feature - Loading Indicator & CancellationToken#3096mthrift2100 wants to merge 2 commits intoMudBlazor:devfrom
Conversation
|
I think if we add a progress, it should be linear, not circular, because MudTable etc. uses linear also. Material guides said that we should select one progress type for whole application for consistency. |
|
Using the linear progress indicator would be easier. It would eliminate the need for a MinHeight / LoadingSize parameter, and could be applied to the bottom edge of the Input control. I think a loading indicator is essential, as is cancellation functionality. In a production setting, the SearchFunc will almost certainly be making an API call to a server, which means there is no guarantee of how long it will take to return a result. A loading indicator will help the user understand what is happening when they start typing. If any of the following occur while the component is awaiting the results of the SearchFunc, the results of the SearchFunc will
|
| @@ -0,0 +1,53 @@ | |||
| @namespace MudBlazor.UnitTests.TestComponents | |||
There was a problem hiding this comment.
Can you please also add a bUnit test?
| @@ -0,0 +1,53 @@ | |||
| @namespace MudBlazor.UnitTests.TestComponents | |||
| @using System.Threading | |||
There was a problem hiding this comment.
I agree with @mckaragoz that a linear progress bar makes more sense. Something like vuetify:

https://vuetifyjs.com/en/components/autocompletes/#asynchronous-items
Can you also add a RenderFragment that is displayed inside the popover while it's loading. Something like this in mui:

https://mui.com/components/autocomplete/#asynchronous-requests
There was a problem hiding this comment.
Acknowledged. When I look at this a bit later, I may have a couple clarifying questions. Thanks!
There was a problem hiding this comment.
@mthrift2100 Any updates with this feature. Will this be added to any of the upcoming releases
|
Hello everyone, definitely a good feature to have. My question is, after this is merged successfully, will it be available for .NET Core 5 version as well as 6? Thank you. |
I know that PR's will added and merged also in net 5, unless it has technical impossibilites with net 5. But of course net 5 cant support forever. |
Thanks. |
|
Will close this for inactivity, just make new PR when you/it is ready. |
|
@henon @Garderoben I am working on a PR. However I am not sure how to test this. IsLoading is set from within OnSearchAsync. So I have to trigger that and see if the loading indicator is displayed. Not sure how to do that. What I've tried: I tested the implementation in the demo and it works fine. |
|
Not sure if it is that easy because of the popup implementation. Did you look if there are any other tests which check what is inside the drop-down? You could learn from them |
Description
Adds the following parameters to support a visual indicator for loading/progress while the MudAutoComplete component is awaiting the results of the SearchFunc Task.
[Parameter] public bool ShowLoading { get; set; }[Parameter] public Size LoadingSize { get; set; } = Size.Medium;[Parameter] public Color LoadingColor { get; set; } = Color.Default;[Parameter] public int MinHeight {get; set;}Adds a
[Parameter] public Func<string, CancellationToken, Task<IEnumerable<T>>> SearchFuncWithCancel { get; set; }parameter which can be used instead of[Parameter] public Func<string, Task<IEnumerable<T>>> SearchFunc { get; set; }.This allows a
CancellationTokento be be passed into the SearchFunc by the MudAutoComplete component. The token is cancelled when the following methods are called:Task OnSearchAsync()Task SelectOption(T value)This allows for expensive asynchronous work to be cancelled before the result is returned, and can then more quickly process the next search (if the user changed the search value).
How Has This Been Tested?
Types of changes
Checklist:
dev).