Skip to content

fix(number-input): ignore name prop in getNumberInputProps#5762

Merged
wingkwong merged 3 commits into
canaryfrom
fix/eng-2742
Oct 4, 2025
Merged

fix(number-input): ignore name prop in getNumberInputProps#5762
wingkwong merged 3 commits into
canaryfrom
fix/eng-2742

Conversation

@wingkwong
Copy link
Copy Markdown
Member

@wingkwong wingkwong commented Oct 3, 2025

Closes #5594

📝 Description

⛳️ Current behavior (updates)

🚀 New behavior

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes

    • Number Input: the name prop is no longer forwarded in generated input props, preventing unexpected name attributes and form conflicts (name is now ignored).
  • Chores

    • Added a changeset entry for a patch release of the Number Input package documenting this behavioral change.
  • Tests

    • Updated Number Input tests to use an encapsulated form test harness and validate behavior via form-integrated interactions.

@wingkwong wingkwong added this to the v2.8.5 milestone Oct 3, 2025
@wingkwong wingkwong requested a review from jrgarciadev as a code owner October 3, 2025 05:59
@linear
Copy link
Copy Markdown

linear Bot commented Oct 3, 2025

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 3, 2025

🦋 Changeset detected

Latest commit: 4867186

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

This PR includes changesets to release 2 packages
Name Type
@heroui/number-input Patch
@heroui/react 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

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
heroui Ready Ready Preview Comment Oct 3, 2025 0:40am
heroui-sb Ready Ready Preview Comment Oct 3, 2025 0:40am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 3, 2025

Walkthrough

Omit the name prop from props forwarded to the visible NumberInput element (in addition to value), add a changeset documenting the patch for @heroui/number-input, and update tests to use a TestForm that wires up react-hook-form for integration-style assertions.

Changes

Cohort / File(s) Summary
NumberInput hook logic
packages/components/number-input/src/use-number-input.ts
Updated getNumberInputProps to omit ["value", "name"] from forwarded props so the visible input no longer receives a name attribute.
Release note / changeset
.changeset/short-ravens-stare.md
Added a patch changeset for @heroui/number-input describing the behavioral change (ignore name in getNumberInputProps) and referencing #5594.
Tests (react-hook-form integration)
packages/components/number-input/__tests__/number-input.test.tsx
Reworked tests to use a TestForm component that registers fields with useForm; replaced direct renderHook/dom queries with hidden form inputs plus a visible input by testId; updated assertions to simulate user typing and submit behavior.

Sequence Diagram(s)

sequenceDiagram
  participant App as App code
  participant NI as NumberInput
  participant Hook as useNumberInput.getNumberInputProps
  participant VInput as Visible input (formatted)
  participant HInput as Hidden input (raw value)

  App->>NI: render NumberInput(name, value, props)
  NI->>Hook: getNumberInputProps(props)
  Note right of Hook #f0f4c3: omit "value" and "name" from merged props
  Hook-->>NI: merged props (no name, no value)
  NI->>VInput: render visible input without `name`
  NI->>HInput: render hidden input with `name` and raw numeric value
  Note over VInput,HInput #e8f5e9: Only hidden input carries the form `name`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • jrgarciadev
  • winchesHe

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description currently only contains the template headings and the issue closure but lacks any filled-out sections describing the change, current behavior, new behavior, breaking change status, or additional information. Please provide detailed content under each template section, including a brief description of the change, the current and new behaviors, whether it is a breaking change, and any additional context or migration guidance.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the main fix—making getNumberInputProps ignore the name prop in the number-input component—which directly aligns with the code changes introduced in this PR.
Linked Issues Check ✅ Passed The changes update getNumberInputProps to omit the name prop so that only the hidden raw-value input retains the name, preventing the visible input from duplicating it, and the updated tests verify this behavior.
Out of Scope Changes Check ✅ Passed All code modifications are directly focused on omitting the name prop in getNumberInputProps and updating tests to reflect the intended behavior, with no unrelated features or files being altered.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/eng-2742

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Oct 3, 2025

Open in StackBlitz

@heroui/accordion

npm i https://pkg.pr.new/@heroui/accordion@5762

@heroui/alert

npm i https://pkg.pr.new/@heroui/alert@5762

@heroui/autocomplete

npm i https://pkg.pr.new/@heroui/autocomplete@5762

@heroui/avatar

npm i https://pkg.pr.new/@heroui/avatar@5762

@heroui/badge

npm i https://pkg.pr.new/@heroui/badge@5762

@heroui/breadcrumbs

npm i https://pkg.pr.new/@heroui/breadcrumbs@5762

@heroui/button

npm i https://pkg.pr.new/@heroui/button@5762

@heroui/calendar

npm i https://pkg.pr.new/@heroui/calendar@5762

@heroui/card

npm i https://pkg.pr.new/@heroui/card@5762

@heroui/checkbox

npm i https://pkg.pr.new/@heroui/checkbox@5762

@heroui/chip

npm i https://pkg.pr.new/@heroui/chip@5762

@heroui/code

npm i https://pkg.pr.new/@heroui/code@5762

@heroui/date-input

npm i https://pkg.pr.new/@heroui/date-input@5762

@heroui/date-picker

npm i https://pkg.pr.new/@heroui/date-picker@5762

@heroui/divider

npm i https://pkg.pr.new/@heroui/divider@5762

@heroui/drawer

npm i https://pkg.pr.new/@heroui/drawer@5762

@heroui/dropdown

npm i https://pkg.pr.new/@heroui/dropdown@5762

@heroui/form

npm i https://pkg.pr.new/@heroui/form@5762

@heroui/image

npm i https://pkg.pr.new/@heroui/image@5762

@heroui/input

npm i https://pkg.pr.new/@heroui/input@5762

@heroui/input-otp

npm i https://pkg.pr.new/@heroui/input-otp@5762

@heroui/kbd

npm i https://pkg.pr.new/@heroui/kbd@5762

@heroui/link

npm i https://pkg.pr.new/@heroui/link@5762

@heroui/listbox

npm i https://pkg.pr.new/@heroui/listbox@5762

@heroui/menu

npm i https://pkg.pr.new/@heroui/menu@5762

@heroui/modal

npm i https://pkg.pr.new/@heroui/modal@5762

@heroui/navbar

npm i https://pkg.pr.new/@heroui/navbar@5762

@heroui/number-input

npm i https://pkg.pr.new/@heroui/number-input@5762

@heroui/pagination

npm i https://pkg.pr.new/@heroui/pagination@5762

@heroui/popover

npm i https://pkg.pr.new/@heroui/popover@5762

@heroui/progress

npm i https://pkg.pr.new/@heroui/progress@5762

@heroui/radio

npm i https://pkg.pr.new/@heroui/radio@5762

@heroui/ripple

npm i https://pkg.pr.new/@heroui/ripple@5762

@heroui/scroll-shadow

npm i https://pkg.pr.new/@heroui/scroll-shadow@5762

@heroui/select

npm i https://pkg.pr.new/@heroui/select@5762

@heroui/skeleton

npm i https://pkg.pr.new/@heroui/skeleton@5762

@heroui/slider

npm i https://pkg.pr.new/@heroui/slider@5762

@heroui/snippet

npm i https://pkg.pr.new/@heroui/snippet@5762

@heroui/spacer

npm i https://pkg.pr.new/@heroui/spacer@5762

@heroui/spinner

npm i https://pkg.pr.new/@heroui/spinner@5762

@heroui/switch

npm i https://pkg.pr.new/@heroui/switch@5762

@heroui/table

npm i https://pkg.pr.new/@heroui/table@5762

@heroui/tabs

npm i https://pkg.pr.new/@heroui/tabs@5762

@heroui/toast

npm i https://pkg.pr.new/@heroui/toast@5762

@heroui/tooltip

npm i https://pkg.pr.new/@heroui/tooltip@5762

@heroui/user

npm i https://pkg.pr.new/@heroui/user@5762

@heroui/react

npm i https://pkg.pr.new/@heroui/react@5762

@heroui/system

npm i https://pkg.pr.new/@heroui/system@5762

@heroui/system-rsc

npm i https://pkg.pr.new/@heroui/system-rsc@5762

@heroui/theme

npm i https://pkg.pr.new/@heroui/theme@5762

@heroui/use-aria-accordion

npm i https://pkg.pr.new/@heroui/use-aria-accordion@5762

@heroui/use-aria-accordion-item

npm i https://pkg.pr.new/@heroui/use-aria-accordion-item@5762

@heroui/use-aria-button

npm i https://pkg.pr.new/@heroui/use-aria-button@5762

@heroui/use-aria-link

npm i https://pkg.pr.new/@heroui/use-aria-link@5762

@heroui/use-aria-modal-overlay

npm i https://pkg.pr.new/@heroui/use-aria-modal-overlay@5762

@heroui/use-aria-multiselect

npm i https://pkg.pr.new/@heroui/use-aria-multiselect@5762

@heroui/use-aria-overlay

npm i https://pkg.pr.new/@heroui/use-aria-overlay@5762

@heroui/use-callback-ref

npm i https://pkg.pr.new/@heroui/use-callback-ref@5762

@heroui/use-clipboard

npm i https://pkg.pr.new/@heroui/use-clipboard@5762

@heroui/use-data-scroll-overflow

npm i https://pkg.pr.new/@heroui/use-data-scroll-overflow@5762

@heroui/use-disclosure

npm i https://pkg.pr.new/@heroui/use-disclosure@5762

@heroui/use-draggable

npm i https://pkg.pr.new/@heroui/use-draggable@5762

@heroui/use-form-reset

npm i https://pkg.pr.new/@heroui/use-form-reset@5762

@heroui/use-image

npm i https://pkg.pr.new/@heroui/use-image@5762

@heroui/use-infinite-scroll

npm i https://pkg.pr.new/@heroui/use-infinite-scroll@5762

@heroui/use-intersection-observer

npm i https://pkg.pr.new/@heroui/use-intersection-observer@5762

@heroui/use-is-mobile

npm i https://pkg.pr.new/@heroui/use-is-mobile@5762

@heroui/use-is-mounted

npm i https://pkg.pr.new/@heroui/use-is-mounted@5762

@heroui/use-measure

npm i https://pkg.pr.new/@heroui/use-measure@5762

@heroui/use-pagination

npm i https://pkg.pr.new/@heroui/use-pagination@5762

@heroui/use-real-shape

npm i https://pkg.pr.new/@heroui/use-real-shape@5762

@heroui/use-ref-state

npm i https://pkg.pr.new/@heroui/use-ref-state@5762

@heroui/use-resize

npm i https://pkg.pr.new/@heroui/use-resize@5762

@heroui/use-safe-layout-effect

npm i https://pkg.pr.new/@heroui/use-safe-layout-effect@5762

@heroui/use-scroll-position

npm i https://pkg.pr.new/@heroui/use-scroll-position@5762

@heroui/use-ssr

npm i https://pkg.pr.new/@heroui/use-ssr@5762

@heroui/use-theme

npm i https://pkg.pr.new/@heroui/use-theme@5762

@heroui/use-update-effect

npm i https://pkg.pr.new/@heroui/use-update-effect@5762

@heroui/use-viewport-size

npm i https://pkg.pr.new/@heroui/use-viewport-size@5762

@heroui/aria-utils

npm i https://pkg.pr.new/@heroui/aria-utils@5762

@heroui/dom-animation

npm i https://pkg.pr.new/@heroui/dom-animation@5762

@heroui/framer-utils

npm i https://pkg.pr.new/@heroui/framer-utils@5762

@heroui/react-rsc-utils

npm i https://pkg.pr.new/@heroui/react-rsc-utils@5762

@heroui/react-utils

npm i https://pkg.pr.new/@heroui/react-utils@5762

@heroui/shared-icons

npm i https://pkg.pr.new/@heroui/shared-icons@5762

@heroui/shared-utils

npm i https://pkg.pr.new/@heroui/shared-utils@5762

@heroui/stories-utils

npm i https://pkg.pr.new/@heroui/stories-utils@5762

@heroui/test-utils

npm i https://pkg.pr.new/@heroui/test-utils@5762

commit: 4867186

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a108e57 and d2fc440.

📒 Files selected for processing (1)
  • packages/components/number-input/__tests__/number-input.test.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: TypeScript
  • GitHub Check: Continuous Release
  • GitHub Check: Build
  • GitHub Check: ESLint

Comment thread packages/components/number-input/__tests__/number-input.test.tsx
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/components/number-input/__tests__/number-input.test.tsx (1)

404-412: Duplicate name assertions properly address the regression.

The new assertions (lines 409-411) correctly verify that only the hidden input carries the name attribute, preventing the regression where both visible and hidden inputs had the same name. This directly addresses the past review concern.

Optional: Consider extending coverage to all fields.

Currently, only requiredField is checked for duplicate names. For thoroughness, consider adding similar assertions for withDefaultValue and withoutDefaultValue to ensure the fix applies consistently across all NumberInput instances.

 expect(hiddenInput1).toHaveValue("1234");
 expect(hiddenInput2).not.toHaveValue();
 expect(hiddenInput3).not.toHaveValue();

+expect(document.querySelectorAll('input[name="withDefaultValue"]')).toHaveLength(1);
+expect(document.querySelectorAll('input[name="withoutDefaultValue"]')).toHaveLength(1);
 expect(document.querySelectorAll('input[name="requiredField"]')).toHaveLength(1);
 expect(visibleInput3).not.toHaveAttribute("name");
 expect(hiddenInput3).toHaveAttribute("name", "requiredField");
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2fc440 and 4867186.

📒 Files selected for processing (1)
  • packages/components/number-input/__tests__/number-input.test.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Prettier
  • GitHub Check: Continuous Release
  • GitHub Check: TypeScript
  • GitHub Check: Tests
  • GitHub Check: Build
🔇 Additional comments (2)
packages/components/number-input/__tests__/number-input.test.tsx (2)

4-4: LGTM!

Adding act from testing-library is appropriate for wrapping React state updates in tests.


422-433: LGTM! Improved test realism.

The test now simulates actual user interaction (clicking and typing) instead of programmatically setting values. The assertion on hiddenInput3 at line 428 correctly verifies that the form state is updated through the onValueChangesetValue flow, which is what matters for form submission.

Comment thread packages/components/number-input/__tests__/number-input.test.tsx
@wingkwong wingkwong merged commit f13c687 into canary Oct 4, 2025
10 checks passed
@wingkwong wingkwong deleted the fix/eng-2742 branch October 4, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - NumberInput adds two input elements with same name attribute

1 participant