MudTablePager: Fix InfoFormat ignoring custom text (#11466)#11468
MudTablePager: Fix InfoFormat ignoring custom text (#11466)#11468ScarletKuro merged 1 commit intoMudBlazor:devfrom
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #11468 +/- ##
=======================================
Coverage 91.16% 91.16%
=======================================
Files 466 466
Lines 14452 14452
Branches 2799 2799
=======================================
Hits 13175 13175
Misses 641 641
Partials 636 636 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR updates the pager’s InfoFormat logic so that custom static text is respected (only empty formats fall back to the default), and adds unit tests to cover custom formatting.
- Changed
MudTablePagerto only use the default localized format whenInfoFormatis null or empty - Renamed the existing default-info test and introduced a new test (
TablePagerInfoTextTest2) for custom formats - Added a test component for verifying custom
InfoFormatexpressions
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/MudBlazor/Components/Table/MudTablePager.razor.cs | Use string.IsNullOrEmpty to decide fallback and always return custom text otherwise |
| src/MudBlazor.UnitTests/Components/TableTests.cs | Renamed default pager info test and added TablePagerInfoTextTest2 for custom behavior |
| src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TablePagerInfoTextTest2.razor | New test component to drive custom InfoFormat scenarios |
Comments suppressed due to low confidence (3)
src/MudBlazor.UnitTests/Components/TableTests.cs:2251
- [nitpick] The test method name
TablePagerInfoTextTest2is non‐descriptive; consider renaming it to something likeTablePagerInfoText_CustomFormatTestfor clarity.
public void TablePagerInfoTextTest2(string infoFormat, string expectedInfoText)
src/MudBlazor.UnitTests/Components/TableTests.cs:2248
- Consider adding a TestCase with a whitespace-only
InfoFormat(e.g." ") to verify it falls back to the default behavior if you switch toIsNullOrWhiteSpace.
[TestCase("", "1-3 of 3")]
src/MudBlazor.UnitTests/Components/TableTests.cs:2213
- The test references a component
TablePagerInfoTextTest1, but no corresponding Razor file was added or updated. Please confirm thatTablePagerInfoTextTest1.razorexists or update the reference.
public void TablePagerInfoTextTest1()
| var lastItem = Math.Min((Table?.CurrentPage + 1) * Table?.RowsPerPage ?? 0, filteredItemsCount); | ||
|
|
||
| if (InfoFormat.Contains("{first_item}") || InfoFormat.Contains("{last_item}") || InfoFormat.Contains("{all_items}")) | ||
| if (string.IsNullOrEmpty(InfoFormat)) |
There was a problem hiding this comment.
[nitpick] Consider using string.IsNullOrWhiteSpace(InfoFormat) to also treat whitespace-only formats as empty and correctly fall back to the default.
| if (string.IsNullOrEmpty(InfoFormat)) | |
| if (string.IsNullOrWhiteSpace(InfoFormat)) |



InfoFormataccepts now custom strings that do not use parameters likefirst_item.Description
Fixes #11466.
How Has This Been Tested?
Created a new unit test for custom InfoFormats.
Type of Changes
Checklist
dev).