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

MudAutocomplete: ItemDisabledTemplate and ItemSelectedTemplate will now display even if ItemTemplate is not defined. #8913

Conversation

digitaldirk
Copy link
Contributor

@digitaldirk digitaldirk commented May 7, 2024

Description

Updated the logic for choosing which template (or just the string) for an item. Previously if the ItemTemplate was null, then ItemDisabledTemplate/ItemSelectedTemplate would not display.
Fixes #8912

How Has This Been Tested?

Visually tested via docs and own project.

Type of Changes

Would this be a visually breaking bug? If someone defined just a ItemDisabledTemplate and no others, before this fix their MudAutocomplete would be "normal" and after this fix then the disabled items could look different. This approach also prioritizes the templates in this order: ItemDisabledTemplate -> ItemSelectedTemplate -> ItemTemplate -> item string. An example to think about: if all these templates were defined, and programmatically we selected an item that is marked as Disabled in a MudAutocomplete then how should it show? I believe disabled is the best choice here but would love to hear opinions about this.

  • 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)
  • Documentation (fix or improvement to the website or code docs)

Docs demo:
DocsItemDisabledTemplateDemo

Current behavior:
You can see how the ItemDisabledTemplate does not display when the ItemTemplate is null here: https://try.mudblazor.com/snippet/GkmIuTaLryaVxwKA

Checklist

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

…emTemplate was null

Previously when ItemTemplate was null, ItemDisabledTemplate/ItemSelectedTemplate would not show. Now ItemDisabledTemplate takes priority, then ItemSelectedTemplate, then ItemTemplate, finally just the string if all are null.
Shows how to use the ItemDisabledTemplate to customize a disabled item.
Reworded text a little, and added ItemDisabledTemplate.
@github-actions github-actions bot added breaking change bug Something does not work as intended/expected PR: needs review labels May 7, 2024
Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.46%. Comparing base (28bc599) to head (0204a76).
Report is 176 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8913      +/-   ##
==========================================
+ Coverage   89.82%   90.46%   +0.63%     
==========================================
  Files         412      419       +7     
  Lines       11878    12189     +311     
  Branches     2364     2380      +16     
==========================================
+ Hits        10670    11027     +357     
+ Misses        681      629      -52     
- Partials      527      533       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ScarletKuro
Copy link
Member

Hi.
Thanks for your PR.
Can you please add a bUnit test so we will be sure that #8912 won't happen again

@ScarletKuro
Copy link
Member

ScarletKuro commented May 8, 2024

@danielchalmers probs will conflict with #8914 as same line was modified

Tests that the ItemDisabledTemplate and ItemSelectedTemplate both can display when ItemTemplate isn't provided (null)
For use with "AutocompleteItemTemplateDisplayTest" Test in AutocompleteTests.cs
@digitaldirk
Copy link
Contributor Author

Test is now added @henon @danielchalmers @ScarletKuro

Test passes on my branch and fails on dev. The test component has both the ItemDisabledTemplate and ItemSelectedTemplate defined and it does not have a ItemTemplate defined

On my branch:
image

On dev:
image

@henon
Copy link
Collaborator

henon commented May 10, 2024

@digitaldirk what would you write in the migration guide? Just a one-liner please

@digitaldirk
Copy link
Contributor Author

@digitaldirk what would you write in the migration guide? Just a one-liner please

ItemDisabledTemplate and ItemSelectedTemplate will now display when a ItemTemplate is not defined.

@henon

@henon henon changed the title MudAutocomplete ItemDisabledTemplate/ItemSelectedTemplate display fix MudAutocomplete: ItemDisabledTemplate and ItemSelectedTemplate will now display even if ItemTemplate is not defined. May 11, 2024
@henon henon merged commit 5af10ff into MudBlazor:dev May 11, 2024
4 checks passed
@henon henon mentioned this pull request May 11, 2024
@henon
Copy link
Collaborator

henon commented May 11, 2024

Thanks @digitaldirk

Added to v7.0.0 Migration Guide #8447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change bug Something does not work as intended/expected PR: needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MudAutocomplete: ItemDisabledTemplate/ItemSelectedTemplate doesn't appear if ItemTemplate is null
4 participants