Aman-Mittal opened a new issue, #620:
URL: https://github.com/apache/fineract-backoffice-ui/issues/620

   Found while working through a real account lifecycle on the deployed build 
(`64a23997`): open a savings account, and the list footer reads
   
   > Items per page: **1 - 10 of NaN**
   
   ![savings accounts 
NaN](https://raw.githubusercontent.com/Aman-Mittal/fineract-backoffice-ui/ux-audit-screens-2026-09-21/screens/savings-accounts-total-nan.jpeg)
   
   It is not a data problem. `GET /savingsaccounts?offset=0&limit=10` answers 
correctly:
   
   ```json
   { "totalFilteredRecords": 1, "pageItems": [ … ] }
   ```
   
   ## Cause
   
   `savings-accounts-list.component.ts:217-224`:
   
   ```ts
   this.totalRecords = response.totalFilteredRecords || 0;   // 1 — correct
   // If server-side count is returned, but we filtered client-side, adjust 
totalRecords accordingly
   if (response.pageItems && response.pageItems.size !== items.length) {
     this.totalRecords = Math.max(
       0,
       this.totalRecords - (response.pageItems.size - items.length),
     );
   }
   ```
   
   `pageItems` is an **array**, so `.size` is `undefined` — `.length` is the 
property it wants. Line 211 above it already treats the value as iterable via 
`Array.from(response.pageItems || [])`, so the type is not in doubt.
   
   That makes the guard and the arithmetic both wrong:
   
   - `undefined !== items.length` is true whenever the page has rows, so the 
correction always runs, including when nothing was filtered out.
   - `1 - (undefined - 1)` is `1 - NaN` → `NaN`, and `Math.max(0, NaN)` is 
`NaN`, not `0`.
   
   So `totalRecords` is `NaN` on **every** load that returns at least one row, 
and the paginator prints it. With zero rows the guard is skipped and the count 
is correct, which is why an empty sandbox looks fine.
   
   ## Reproduction
   
   1. Have at least one savings account.
   2. Open **Products → Savings Accounts**.
   3. Read the footer: `1 - 10 of NaN`.
   
   Reproduced on every load through the lifecycle — after create, after 
approve, after activate, after a deposit.
   
   ## Suggested fix
   
   ```diff
   -  if (response.pageItems && response.pageItems.size !== items.length) {
   +  if (response.pageItems && response.pageItems.length !== items.length) {
        this.totalRecords = Math.max(
          0,
   -      this.totalRecords - (response.pageItems.size - items.length),
   +      this.totalRecords - (response.pageItems.length - items.length),
        );
      }
   ```
   
   Worth a test that asserts the count for a response whose `pageItems` all 
survive the client-side filter, since that is the case the current guard gets 
wrong and the one that ships.
   
   `.size` on a response payload appears nowhere else in `src/app` — the other 
`.size` uses are genuine `Set`s — so this looks contained to this component.
   
   ## Also seen on the same screen
   
   The range reads `1 - 10` while one record is displayed. That is the 
paginator deriving the range from the page size; it should resolve once the 
total is a number, but worth confirming as part of the fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to