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

Autocomplete: Add MoreItemsTemplate RenderFragment. #4566

Merged
merged 3 commits into from May 16, 2022

Conversation

Mr-Technician
Copy link
Member

Description

This PR adds a <MoreItemsTemplate> render fragment to the autocomplete. The component has a means of limiting the items displayed but provides no indication to the user that the list of items may be truncated. This PR provides a means of displaying a render fragment in the number of items returned from the SearchFunc is greater than the MaxItems count.

For example:

<MudAutocomplete T="string" Label="US States" @bind-Value="value1" SearchFunc="@Search1"
ResetValueOnEmptyText="@resetValueOnEmptyText"
CoerceText="@coerceText" CoerceValue="@coerceValue" MaxItems="10">
    <MoreItemsTemplate>
        <MudText Align="Align.Center">
        Not all items are shown.
        </MudText>
    </MoreItemsTemplate>
</MudAutocomplete>

image

My biggest caveat is the items IEnumerable must be enumerated twice, once to get the count of items, and once to take the appropriate number according to MaxItems. There may be a way to better optimize this (I don't care how long the items IEnumberable is, provided it is longer than MaxItems).

How Has This Been Tested?

I have added a unit test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@Mr-Technician
Copy link
Member Author

@Garderoben I believe this is in your area.

@Mr-Technician
Copy link
Member Author

Actually @henon this might be more for you, what do you think of this change?

@henon
Copy link
Collaborator

henon commented May 16, 2022

I approve of this addition. Could be used to implement a "Show more" or "Show all" functionality.

@Mr-Technician
Copy link
Member Author

@henon I've made the change you requested. Should this feature have its own docs section or is its presence under the API enough?

@codecov
Copy link

codecov bot commented May 16, 2022

Codecov Report

Merging #4566 (c62a453) into dev (e8536f8) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #4566      +/-   ##
==========================================
+ Coverage   91.27%   91.30%   +0.03%     
==========================================
  Files         362      362              
  Lines       12481    12502      +21     
==========================================
+ Hits        11392    11415      +23     
+ Misses       1089     1087       -2     
Impacted Files Coverage Δ
...azor/Components/Autocomplete/MudAutocomplete.razor 94.44% <100.00%> (+0.69%) ⬆️
...r/Components/Autocomplete/MudAutocomplete.razor.cs 94.25% <100.00%> (+0.05%) ⬆️
...azor/Services/ResizeListener/BreakpointService .cs 93.02% <0.00%> (-0.09%) ⬇️
...azor/Components/DatePicker/MudBaseDatePicker.razor 97.72% <0.00%> (-0.06%) ⬇️
src/MudBlazor/Components/Input/MudInput.razor 100.00% <0.00%> (ø)
.../MudBlazor/Components/TextField/MudTextField.razor 100.00% <0.00%> (ø)
src/MudBlazor/Components/Select/MudSelect.razor.cs 96.75% <0.00%> (+0.03%) ⬆️
src/MudBlazor/Base/MudFormComponent.cs 87.98% <0.00%> (+0.05%) ⬆️
...azor/Components/DropZone/MudDropContainer.razor.cs 97.50% <0.00%> (+0.06%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8536f8...c62a453. Read the comment docs.

@henon henon merged commit 21c5dc6 into MudBlazor:dev May 16, 2022
@henon henon added enhancement New feature or request API change API that needs approval labels May 16, 2022
@henon henon added this to the 6.0.11 milestone May 16, 2022
@Mr-Technician Mr-Technician deleted the autocomplete-more-items branch May 16, 2022 16:48
@Yomodo
Copy link
Contributor

Yomodo commented May 16, 2022

@henon I've made the change you requested. Should this feature have its own docs section or is its presence under the API enough?

I believe this nifty feature deserves its own docs section.

@henon
Copy link
Collaborator

henon commented May 16, 2022

You are right of course. I overlooked that question from @Mr-Technician, sorry.

@Mr-Technician
Copy link
Member Author

I can add a docs section this evening (or at some point in the next few days at least) but I'll make a new PR since this one is already merged.

jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
3dots pushed a commit to 3dots/MudBlazor that referenced this pull request Mar 23, 2023
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
ScarletKuro pushed a commit to ScarletKuro/MudBlazor that referenced this pull request Mar 27, 2023
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
ferraridavide pushed a commit to ferraridavide/MudBlazor that referenced this pull request May 30, 2023
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
ilovepilav pushed a commit to ilovepilav/MudBlazor that referenced this pull request Nov 25, 2023
* Autocomplete: Add MoreItemsTemplate RenderFragment.

* Fix unit test.

* Always count returned items on search.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change API that needs approval enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants