Skip to content

MudTablePager: Fix InfoFormat ignoring custom text (#11466)#11468

Merged
ScarletKuro merged 1 commit intoMudBlazor:devfrom
sirdx:fix-mudtablepager-custom-infoformat
Jun 9, 2025
Merged

MudTablePager: Fix InfoFormat ignoring custom text (#11466)#11468
ScarletKuro merged 1 commit intoMudBlazor:devfrom
sirdx:fix-mudtablepager-custom-infoformat

Conversation

@sirdx
Copy link
Contributor

@sirdx sirdx commented Jun 9, 2025

InfoFormat accepts now custom strings that do not use parameters like first_item.

Description

Fixes #11466.

How Has This Been Tested?

Created a new unit test for custom InfoFormats.

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

Checklist

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

@github-actions github-actions bot added the bug Unexpected behavior or functionality not working as intended label Jun 9, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 9, 2025

@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.16%. Comparing base (9db7109) to head (f8ec04d).
Report is 2 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielchalmers danielchalmers requested a review from Copilot June 9, 2025 18:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MudTablePager to only use the default localized format when InfoFormat is 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 InfoFormat expressions

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 TablePagerInfoTextTest2 is non‐descriptive; consider renaming it to something like TablePagerInfoText_CustomFormatTest for 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 to IsNullOrWhiteSpace.
[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 that TablePagerInfoTextTest1.razor exists 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))
Copy link

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using string.IsNullOrWhiteSpace(InfoFormat) to also treat whitespace-only formats as empty and correctly fall back to the default.

Suggested change
if (string.IsNullOrEmpty(InfoFormat))
if (string.IsNullOrWhiteSpace(InfoFormat))

Copilot uses AI. Check for mistakes.
@ScarletKuro ScarletKuro merged commit 774ed5d into MudBlazor:dev Jun 9, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudTablePager's InfoFormat ignores custom text when not using {first_item}/{last_item}/{all_items}

5 participants