Skip to content

fix(platform): format product list prices in the reader's locale - #4205

Merged
yannickmonney merged 1 commit into
mainfrom
fix/products-price-column-locale
Oct 4, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/products-price-column-locale

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The products list formatted every Price in English, whatever the reader's language. The product details dialog got it right. For 1234.56 EUR, a French reader saw €1,234.56 in the list and 1 234,56 € in the details.

  • Root cause: use-products-table-config.tsx called formatCurrency(price, currency) with no locale, so it fell back to the default en. The column builder couldn't do better: createTableConfigHook gave builders translations but not the active locale, and a column builder can't call a hook.
  • Fix: createTableConfigHook now reads useLocale() and passes locale to its column builders. locale is also in the column memo's dependencies, so the columns are rebuilt when the language changes. This is how the hand-built documents table config already reads the locale. The Price cell passes locale to formatCurrency, the same call the details dialog makes. The details dialog itself is untouched; it stays the control.
  • Manual register: tests/manual/reference/automation.md has a new row recording that the spec owns this behaviour.

The change is display-only. No request, response, contract or stored value changes; the price is read and saved exactly as before.

How I verified it

  • Red first, at the failing boundary. The new price column cases in products-table.test.tsx render the real ProductsTable under the real AppShell locale/i18n providers. Each case reads the row's Price cell, clicks the row to open the real details dialog, and compares the two. On main (6524150fe):
    × formats the price for fr-FR as the product details do
      -   "tablePrice": "1 234,56 €",
      +   "tablePrice": "€1,234.56",
          "detailsPrice": "1 234,56 €",
    × formats the price for de-DE as the product details do
      +   "tablePrice": "€1,234.56"   (details: "1.234,56 €")
    Tests  2 failed | 8 passed (10)
    
    This matches the issue's frozen PRODUCT_PRICE_LOCALE observation. The details dialog (the control) and the en-US case passed both before and after the fix.
  • Green after the fix: the regression plus every test of a file that imports the changed modules (the products, contacts and websites table and table-config tests, and product-view-dialog.test.tsx). Result: Test Files 7 passed (7) · Tests 37 passed (37) with vitest.ui.config.ts (jsdom).
  • Lint and format: oxlint --type-aware on the changed files is clean, and oxfmt --check passes. bun run lint:manual is ok (5 trees, 1442 boxes).
  • Typecheck: a scoped tsc over the changed files, the three factory consumers, the router registration and the ambient types passed with exit 0 (6,178 files). I did not run the whole-platform tsc locally; the Type check job runs it.

Sweep

  • Accessibility: the cell markup is the same <span>, so nothing changes for assistive technology.
  • en / de / fr: no strings were added or changed. The amount now follows Intl for the active locale in both places (fr-FR 1 234,56 €, de-DE 1.234,56 €, en-US €1,234.56).
  • Docs: none needed. docs/en/platform/knowledge/structured-data.md says the list shows the price but doesn't specify a format.
  • Other factory tables: contacts and websites format no numbers, so they only gain an unused locale.

Not covered

Closes #3619

The products list's Price cell called formatCurrency without a locale, so it
fell back to the default `en` and showed `€1,234.56` to a French or German
reader while the product details showed `1 234,56 €`. The table config
factory now hands its column builders the active locale and recomputes the
columns when it changes, as the documents table config does, and the Price
cell passes it on.

Closes #3619
@yannickmonney yannickmonney added bug Bug service: platform Platform service labels Oct 4, 2026
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review of PR #4205 at 1e3a3266f7e3d836ace6cea78e61408a020f401d: accepted from source and tests. The merge waits for terminal exact-head CI.

Runtime (mine)

  • Negative control: with main's use-products-table-config.tsx and use-table-config-factory.ts, the head's products-table.test.tsx fails 2 of 10 (fr-FR and de-DE). At the head it passes 10/10.
  • No browser render: the change only passes a locale into an existing cell. The formatting runs through the real Intl in the jsdom tests.

Verified from source

  • The list and the details read the same locale. The factory reads useLocale() from the shared provider (use-table-config-factory.ts:4,119). The details dialog gets the same value through useFormatDate().locale (product-view-dialog.tsx:34).
    • Both make the same call, formatCurrency(price, currency || 'USD', locale), behind the same price !== undefined guard (use-products-table-config.tsx:78-82, product-view-dialog.tsx:50-54).
    • They therefore agree for every locale tag, including de-CH, and for any currency.
  • formatCurrency is unchanged. Only the third argument is new.
  • Every factory consumer is covered. Contacts and websites also use the factory; neither destructures locale, and every render site sits under the provider. useLocale would throw without one.
  • A locale switch rebuilds the Price cell. locale is in the column memo deps (:142), and the context value is memoized, so this adds no render cost.

Follow-ups (none block)

  1. LOW: no test switches the locale at runtime. A stale-copy mutant (reading the locale once at mount) stays green. Dropping locale from the deps is caught only by Lint (react/exhaustive-deps is an error). A test that renders en-US, switches to fr-FR and asserts the Price cell would close this.
  2. LOW: the fixture is always a non-zero EUR price, so the currency || 'USD' fallback, a price of 0 and an undefined price are untested in the list. A de-CH row would also be worth adding. This code predates the PR.
  3. INFO: the products Stock column shows the raw number (use-products-table-config.tsx:62), while the details format it per locale (12,345 units / 12.345 Einheiten). The websites Indexed count is ungrouped in both list and details.

CI: at 01:55Z the exact head had 16 of 21 checks still queued, including Lint, Type check and UI, with none failed. I'll merge only once every check is terminal and acceptable at this exact head, squashing with --match-head-commit through my gate.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

TALE-525 reconciliation — ACCEPT record reused; no new merge authorization

PR #4205 head is still 1e3a3266f7e3d836ace6cea78e61408a020f401d (confirmed again 2026-10-04 02:09Z). Implementation agent #3/run 20895ddf is distinct from this reviewer, agent #6 8c78cac9, TALE-525 run fd75675d.

Already done: reading TALE-164 and the latest TALE-359 discussion revealed that agent #2 had already independently accepted this exact head in record 5975581548, before this task was dispatched. TALE-359 coordination comment e5f14de2 explicitly identifies this duplicate. I stop redundant review work and reuse that ACCEPT record rather than claim a second completed runtime review. The merge still waits for terminal acceptable exact-head CI and stays with the authorized merger; this receipt does not decide the protected native task review.

Source corroboration completed before reconciliation: the factory passes the shared useLocale() value to column builders and includes locale in the column memo dependencies. The price cell now calls formatCurrency(price, currency || 'USD', locale) exactly as the unchanged details-dialog control does. Contacts and websites are the only other factory consumers; they ignore the additive field and their existing provider-backed test wrappers remain compatible. No request, stored data, formatter or dialog changes. No new blocking source finding. The existing record's nonblocking runtime-switch/edge-case coverage gaps remain; I did not independently close them.

Merge-order check: #4207 at 4299f5b0d476f5467ed2e69474ad171d66880836 adds another row in services/platform/tests/manual/reference/automation.md, but at a different insertion point. Read-only git merge-tree <common-base> <4205-head> <4207-head> produced no conflict markers. No present merge-order conflict between these exact heads; retain both register rows if later rebasing creates overlap.

My attempted proof (not green): targeted jsdom invocation for the seven products/contacts/websites table/config suites and product details control, one worker, 2 GiB Node heap. Initial launch lacked node on PATH; after using the existing /opt/node/bin, all seven suites failed before collection because Vite denied a symlinked existing dependency font URL outside the isolated snapshot (@fontsource/inter/...woff2?url). Zero tests executed. This is an isolated-checkout harness problem, not evidence of a product assertion failure. No dependency installation or further redundant test rerun after discovering the completed review. The prior reviewer reports independently observed red 2/10 on main and green 10/10 at this head; the author reports 37/37 across seven suites. Those are attributed evidence, not my results.

CI read 02:09Z: 36 visible checks: 6 passed, 24 queued/pending, 6 skipped, 0 failed. This includes newly visible build checks and supersedes the earlier 21-check snapshot; pending is not green. No CI rerun or cancellation.

Unrun: browser/layout/visual gate, E2E, stack, containers, HTTP/request/readback, full suites, lint/format/typecheck in this review run. Light-only restriction honored; display-only source reviewed, no live UI/readback claim. Disk preflight had 262 GiB free, above the 20 GiB floor. Shared checkout unchanged; no commit, push, merge or card move.

Deliverables in TALE-525 delivery box: this record, attempted-test log, exact-head CI JSON, check summary JSON, merge-order output and planning note. The generated source snapshot is removed after inspection; no other task's files are altered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug service: platform Platform service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Products price column ignores the active locale while details format it correctly

1 participant