Autocomplete: Improve menu behavior#8787
Conversation
|
@ScarletKuro Could you try your scenarios with this PR |
|
@henon @ScarletKuro Why does the SearchFunc throw an exception here with this PR on the Strict Mode example on the docs? |
|
Please set a breakpoint and find out what the exception and the stacktrace are and post it here. |
|
Sorry, but I really don't know. I have no codebase knowledge on how this component functions at slightest. @henon @mckaragoz has more experience with this component. |
|
@ScarletKuro I think I've definitely hardened the code and made it less brittle and susceptible to race conditions. It does need some heavy testing though. I would hate to discard these changes from the BCL because it has a lot of improvements for all users. |
|
The exception means that the json coming from the web api is invalid. For whatever reason. I can't see why your changes would cause that |
|
Maybe you can find out what the api call returns that can't be parsed? |
Probably the result is returned as plain text (server error) while json is expected. |
|
@henon @Yomodo Seeing it with this call: await SearchFunc(null, _cancellationTokenSrc.Token);In private async Task<IEnumerable<Element>> Search(string value, CancellationToken token)
{
return await httpClient.GetFromJsonAsync<List<Element>>($"webapi/periodictable/{value}", token);
}and public async Task<IEnumerable<string>> Search(string text, CancellationToken token)
{
await Task.Delay(100, token);
if (string.IsNullOrWhiteSpace(text))
{
return Fruits;
}
return Fruits.Where(x => x.Contains(text, StringComparison.InvariantCulture));
}Can you see any reason it would stop working? |
|
Does it even work without your changes? |
@henon Works on https://dev.mudblazor.com/components/autocomplete#strict-mode |
@danielchalmers I've seen this error before when I expect JSON but get HTML, such as when I forget to authenticate an HttpClient request. If we can get the raw response from the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #8787 +/- ##
==========================================
+ Coverage 89.82% 90.12% +0.29%
==========================================
Files 412 421 +9
Lines 11878 12213 +335
Branches 2364 2410 +46
==========================================
+ Hits 10670 11007 +337
+ Misses 681 664 -17
- Partials 527 542 +15 ☔ View full report in Codecov by Sentry. |
Yes, but try to execute it locally instead from dev.mudblazor.ocm. It may well be the cause of the error. |
|
@henon Should have pinged you above but I got it all working except the example because the webapi returns 404 in debug mode which is not a regression. PR should be ready to review |
Are you starting docs as wasm standalone? There is WasmHost then the API should be available. |
|
The Unless somebody can think of a valid use-case for |
Yes this. wasm standalone doesnt have any mvc controllers to provide the endpoints for the examples data. |
|
We want to retain the Strict==false behavior and remove the Strict==true behavior. |
This reverts commit f63501b.
henon
left a comment
There was a problem hiding this comment.
The changes look good. I don't see any red flags. Of course, you can never know with an unstable component like this which was in a delicate balance before. Let's merge and hope for the best. If this introduces issues we can always revert.
not typical behavior and you can just use tab now kind of stops you from closing dialogs with double escape though
|
@Mr-Technician @ScarletKuro Looks good? EDIT: Wait for Mr-Technician before merging |


Description
Follows up on #8758:
New API, Refactor, Prevent race conditions, Fix menu flashing, Update tests.
This is a must-have for v7-preview1 because of the menu flashing bug in the docs on Firefox.
Goal
To make the Autocomplete's menu more stable, extensible, and predictable.
Improvements to API & Behaviour
ChangeMenuAsyncwith clearly defined publicOpenMenuAsyncandCloseMenuAsyncSelectOnClicktoSelectOnActivationfor clarityResolved Issues
onclickandonfocusconflictHow Has This Been Tested?
unit
Type of Changes
Checklist
dev).