fix(number-input): ignore name prop in getNumberInputProps#5762
Conversation
🦋 Changeset detectedLatest commit: 4867186 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
WalkthroughOmit the Changes
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`
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
@heroui/accordion
@heroui/alert
@heroui/autocomplete
@heroui/avatar
@heroui/badge
@heroui/breadcrumbs
@heroui/button
@heroui/calendar
@heroui/card
@heroui/checkbox
@heroui/chip
@heroui/code
@heroui/date-input
@heroui/date-picker
@heroui/divider
@heroui/drawer
@heroui/dropdown
@heroui/form
@heroui/image
@heroui/input
@heroui/input-otp
@heroui/kbd
@heroui/link
@heroui/listbox
@heroui/menu
@heroui/modal
@heroui/navbar
@heroui/number-input
@heroui/pagination
@heroui/popover
@heroui/progress
@heroui/radio
@heroui/ripple
@heroui/scroll-shadow
@heroui/select
@heroui/skeleton
@heroui/slider
@heroui/snippet
@heroui/spacer
@heroui/spinner
@heroui/switch
@heroui/table
@heroui/tabs
@heroui/toast
@heroui/tooltip
@heroui/user
@heroui/react
@heroui/system
@heroui/system-rsc
@heroui/theme
@heroui/use-aria-accordion
@heroui/use-aria-accordion-item
@heroui/use-aria-button
@heroui/use-aria-link
@heroui/use-aria-modal-overlay
@heroui/use-aria-multiselect
@heroui/use-aria-overlay
@heroui/use-callback-ref
@heroui/use-clipboard
@heroui/use-data-scroll-overflow
@heroui/use-disclosure
@heroui/use-draggable
@heroui/use-form-reset
@heroui/use-image
@heroui/use-infinite-scroll
@heroui/use-intersection-observer
@heroui/use-is-mobile
@heroui/use-is-mounted
@heroui/use-measure
@heroui/use-pagination
@heroui/use-real-shape
@heroui/use-ref-state
@heroui/use-resize
@heroui/use-safe-layout-effect
@heroui/use-scroll-position
@heroui/use-ssr
@heroui/use-theme
@heroui/use-update-effect
@heroui/use-viewport-size
@heroui/aria-utils
@heroui/dom-animation
@heroui/framer-utils
@heroui/react-rsc-utils
@heroui/react-utils
@heroui/shared-icons
@heroui/shared-utils
@heroui/stories-utils
@heroui/test-utils
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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
There was a problem hiding this comment.
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
nameattribute, 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
requiredFieldis checked for duplicate names. For thoroughness, consider adding similar assertions forwithDefaultValueandwithoutDefaultValueto 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
📒 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
actfrom 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
hiddenInput3at line 428 correctly verifies that the form state is updated through theonValueChange→setValueflow, which is what matters for form submission.
Closes #5594
📝 Description
⛳️ Current behavior (updates)
🚀 New behavior
💣 Is this a breaking change (Yes/No):
📝 Additional Information
Summary by CodeRabbit
Bug Fixes
Chores
Tests