Skip to content

fix(fields): an empty currency box shows the field's own placeholder, or none, instead of 0.00 (#27398) - #28003

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-33vhr1
Oct 30, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-33vhr1

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe

Requested by Bill · project thread

维护者速读

  • 改了什么:金额输入框为空时不再显示占位符「0.00」(百分比输入框的「0」同样去掉),只显示字段自己声明的占位符,没有就留空。公开表单、记录表单、表格内联编辑三处都生效。
  • 为什么改:HotCRM 的「联系我们」公开表单里,没人填的「年收入」看起来像已经填了 0;日元这类无小数的币种还被提示两位小数。
  • 风险与回滚:一行改动,形状与数字字段(NumberField)一致;字段自带的占位符、表单行覆盖的占位符、真实的 0 都照旧显示。回滚即还原这一行。
  • 先看:ui/packages/fields/src/widgets/CurrencyField.tsx(placeholder 那一行);ui/packages/fields/src/__tests__/CurrencyField.emptyPlaceholder-27398.test.tsx;ui/apps/console/src/components/FormPage.currencyPlaceholder-27398.test.tsx。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/fields/src/__tests__/CurrencyField.emptyPlaceholder-27398.test.tsx apps/console/src/components/FormPage.currencyPlaceholder-27398.test.tsx,预期 2 个文件 10 个用例全绿。
  • 需要你做的:无,席位落地。

Fixes #27398
Clause-②: no
Metadata-protocol: none

What changes

Row 2 of #27398 (row 1 is #27606; row 3 is carded, see Acceptance notes).

  • CurrencyField (edit mode) passed placeholder={field.placeholder || '0.00'} to its number input, so an empty optional amount with no declared placeholder showed 0.00, which reads as a filled-in zero. An authored empty placeholder was replaced by 0.00 too, and a zero-decimal currency (JPY) was offered a two-decimal stand-in. It now passes the field's own placeholder, or none, the same shape NumberField has.
  • One change point covers every host: the public form page (FormPage, through the lazy field-widget registry, handing the row's merged placeholder), the record form (the form renderer's currency widget) and the grid's inline editor (FieldEditWidget) all draw this widget with the field they were handed. No host passes a placeholder of its own that the old fallback was standing in for.
  • Hosts that relied on the 0.00 hint, measured on origin/main at 4a5396b: none. No test, e2e spec, doc or README asserts it; the only 0.00 placeholders in the tree are authored ones (ui/examples/schema-catalog currency and number samples, a FlowRunner number field fixture), and an authored placeholder is still shown.
  • Changeset: @object-ui/fields patch.

Tests

  • ui/packages/fields/src/__tests__/CurrencyField.emptyPlaceholder-27398.test.tsx (7 cases): the widget with no placeholder, with JPY, with an authored empty placeholder, two controls (authored placeholder shown, a real zero shown as a value), and the two package hosts: the form renderer and FieldEditWidget.
  • ui/apps/console/src/components/FormPage.currencyPlaceholder-27398.test.tsx (3 cases): the real public route /f/:slug over a served payload: an empty optional amount has no placeholder; controls for the object field's placeholder and the form row's override.
Runs
  • New files: Test Files 2 passed (2), Tests 10 passed (10).
  • Ablation (fix reverted to the || '0.00' fallback through scripts/ablation-replace.mjs, restored with blob equal to HEAD and an empty git diff HEAD): Tests 6 failed | 4 passed (10). The 6 reds are every no-placeholder pin across the widget, both package hosts and the public form; the 4 greens are the controls.
  • pnpm --dir ui exec vitest run packages/fields/: Test Files 285 passed | 1 skipped (286), Tests 4349 passed | 7 skipped (4356).
  • pnpm --filter @object-ui/fields run type-check: exit 0.

Acceptance notes

Per-row disposition of #27398 rows 2–3, re-measured on origin/main at 4a5396b:

Row Bucket Reason
2 · empty currency shows 0.00 TAKE This PR.
3a · thank-you text cannot name the created record CARD (spec, then server) The thank-you title / message are plain strings with no template slot, and POST /api/v1/forms/:slug/submit answers { id } only on purpose: the form-routes comment says the stored row can carry values an elevated hook derived from records the anonymous grant may never read, so the answer echoes nothing the insert stored. Naming a case number re-opens that trade-off, which is a contract decision, not a renderer change.
3b · submitBehavior text is not translated CARD (spec) Not ui-only. The translation bundle's _views.VIEW entry (strict) declares label, description, title, emptyState and bulkActions, and no submitBehavior copy; translateView overlays only bulkActionDefs, sections and title. The public form door already serves the translated view config under Accept-Language, and the page reads form.submitBehavior from it, so a spec-side key plus overlay reaches both form pages with no ui change.

The seat filed both cards: 3a is #28005, 3b is #28004. PercentField fell back to the placeholder 0 the same way; on the seat's rework it is fixed here too, as one line in PercentField.tsx pinned by PercentField.emptyPlaceholder-27398.test.tsx, and the changeset names it.

Verification

Local gate subset derived by node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on this diff, each recorded with its exit code before any pipe and reconciled with --ran; every family CI runs is read from this PR's check-runs.


Generated by Claude Code

… or none

The edit-mode CurrencyField fell back to the placeholder 0.00 when the
field declared none, so an optional amount nobody filled in read as a
filled-in zero. It now reads the field's placeholder the way NumberField
does.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CZBg559ZS19rzt9ki8
…or none

PercentField fell back to the placeholder 0, which beside its % adornment
read as a filled-in 0%. Same shape as the CurrencyField fix.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CZBg559ZS19rzt9ki8
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe

席位核对

ACCEPT · head e2b63076a89a7247cef8203c2549315312f919dc · 2026-10-30T07:38Z


Generated by Claude Code

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

Labels

documentation Improvements or additions to documentation size/m tooling

Projects

None yet

1 participant