Skip to content

fix(blocks): accept in-range decimals in number inputs - #5133

Open
justincavery wants to merge 3 commits into
emdash-cms:mainfrom
justincavery:fix/block-kit-number-input-decimals
Open

justincavery wants to merge 3 commits into
emdash-cms:mainfrom
justincavery:fix/block-kit-number-input-decimals

Conversation

@justincavery

@justincavery justincavery commented Nov 25, 2026 •

Copy link
Copy Markdown

What does this PR do?

Allows in-range decimals in Block Kit forms and in sandboxed plugin field widgets in the content editor. The default HTML step of one caused a form with a minimum of 0.01 to reject a £5.00 price. It also prevented a content editor widget from saving 5.25 when the author pressed Enter.

Both renderers now use step="any". The field widget also passes the plugin's declared min and max to the number input. Related content editor fix #3791

Closes #5132

Type of change

  • Bug fix
  • Feature (requires an accepted feature plan or RFC)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Your connection to this change

  • I use EmDash and ran into the problem this PR addresses
  • I maintain a tool, dependency, or service that EmDash uses, and this change concerns that integration
  • A Maintainer approved this specific change before I opened the PR

The failure surfaced while setting a price in EmDash Memberships. The standalone Block Kit Playground reproduces it with a single number field.

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). The fix changes a native HTML attribute and adds no admin UI strings.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to their merged design PR. This is a bug fix.
  • I have included screenshots below if this PR changes the UI

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: OpenAI Codex (GPT-6.2 Astra). Codex prepared the patch, regression tests, screenshots, and PR text.

Screenshots / test output

Block Kit form

Before After
Price 5.00 triggers a browser validation message and the Action Log has zero entries. The same 5.00 input dispatches one save_price form submission with numeric price 5.

Sandboxed field widget in the content editor

Before After
The content editor contains a price of 5.25. Chromium suggests 5 or 6 and blocks Enter from saving the entry. The content editor accepts the same 5.25 after Enter and the validation message clears.

On the published 1.6.0 renderer, submitting 5.25 dispatched zero actions with no minimum, a zero minimum, or a minimum of 0.01. Each dispatched one numeric price after the patch. The Chromium content editor test also saved 5.25 and rejected 0 and 10.01 for a widget declaring the range 0.01–10.

  • All 176 Block Kit tests passed.
  • All 230 Chromium tests in ContentEditor.test.tsx and embedded-plugin-form.test.tsx passed.
  • The root build, typecheck, and lint passed. Type-aware lint reported zero diagnostics.

HTML number inputs use a default step of one from the minimum. Let number_input accept in-range decimal values so browser validation allows Block Kit forms to dispatch form_submit.
@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ecbfdf9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@emdash-cms/blocks Patch
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/plugin-test Patch
@emdash-cms/plugin-embeds Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/auth Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet size/S labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach is right: step="any" removes the browser's default step of 1 on number_input while keeping native min/max validation, and it matches what ContentEditor and RepeaterField already do. The regression test uses the reporter's case (min: 0.01, values 5.00 and 5.25) and checks the numeric payload, so it would fail if the step regressed. Both reviewers approved the code change. One reviewer raised two points: the changeset describes only one case of the bug, and the same bug exists in the admin content editor's BlockKitFieldWidget. The other reviewer found no issues. The advisory verdict is comment because the changeset finding is marked needs_fixing.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

A focused number input could block saving the content editor with Enter. Use the declared range for validation and cover decimal saves with a zero, fractional, or unspecified minimum.
@emdashbot emdashbot Bot added review/needs-review No maintainer or bot review yet and removed review/needs-review No maintainer or bot review yet labels Nov 25, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The follow-up takes the right approach: applying step="any" to sandboxed field widgets fixes the same decimal-validation problem on the content-editor path, while forwarding the declared bounds preserves range validation.

Both earlier findings are addressed. The changeset now describes decimal inputs generally and includes the admin package. The expanded tests cover absent and zero minimums, and the new editor regression checks numeric decimal saving via Enter and invalid range values.

I reviewed the follow-up diff, surrounding widget and editor code, regression tests, and changeset guidance. No new issues found. Review was static; I did not run tests or builds.


Follow-up review by openai/gpt-6.1-sol, scoped to the changes since the last review.

@justincavery

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block Kit number_input rejects in-range prices when min is 0.01

1 participant