Skip to content

fix(number-input): include labelPlacement in dependency array#5866

Merged
wingkwong merged 5 commits into
heroui-inc:canaryfrom
KumJungMin:fix/issue-5845
Nov 2, 2025
Merged

fix(number-input): include labelPlacement in dependency array#5866
wingkwong merged 5 commits into
heroui-inc:canaryfrom
KumJungMin:fix/issue-5845

Conversation

@KumJungMin
Copy link
Copy Markdown
Contributor

@KumJungMin KumJungMin commented Nov 2, 2025

Closes #5845

📝 Description

  • Updated NumberInput to inherit the labelPlacement setting from HeroUIProvider.
  • Previously, the global labelPlacement (e.g., "outside") defined in HeroUIProvider was not applied to NumberInput.
<HeroUIProvider labelPlacement="outside">
  <NumberInput
    isRequired
    name="total"
    placeholder="Enter amount"
    label="Total amount"
    aria-label="Total"
  />
</HeroUIProvider>

Problem:
The label was expected to be placed outside, but it was rendered inside instead.

스크린샷 2025-11-02 오후 3 45 19



  • This fix ensures labelPlacement is properly passed into the hook and slot calculation so the component correctly reflects the global configuration.

Solved:
The label is now correctly rendered outside as expected.

스크린샷 2025-11-02 오후 3 44 35



⛳️ Current behavior (updates)

  • NumberInput does not respect the global labelPlacement value from HeroUIProvider.
  • The label is always rendered using the default "inside" placement.

🚀 New behavior

  • NumberInput now automatically inherits the labelPlacement value from HeroUIProvider.
  • The prop labelPlacement on NumberInput can still override the global value if specified.

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

No


📝 Additional Information

  • Added labelPlacement to the numberInput() style generator and dependency array in useMemo, ensuring reactive updates when the global provider changes.
  • Behavior is now consistent with the Input component.

Summary by CodeRabbit

  • New Features

    • NumberInput now inherits labelPlacement from HeroUIProvider, letting you set a default label placement at the provider level; individual NumberInput components can still override it.
  • Tests

    • Added tests confirming NumberInput respects HeroUIProvider labelPlacement and that explicit props take precedence.
  • Chores

    • Added a changeset recording the bump to the NumberInput package.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 2, 2025

🦋 Changeset detected

Latest commit: b595ea7

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 Nov 2, 2025

@KumJungMin is attempting to deploy a commit to the HeroUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 2, 2025

Walkthrough

Adds a changeset and tests, and updates the NumberInput hook to read labelPlacement from HeroUIProvider and thread it into variant/slot generation so label placement can be inherited from context while still allowing explicit prop override.

Changes

Cohort / File(s) Summary
Changeset
.changeset/brave-laws-enjoy.md
New changeset entry bumping @heroui/number-input to patch and noting feature: allow inheriting labelPlacement from HeroUIProvider.
Tests
packages/components/number-input/__tests__/number-input.test.tsx
Adds HeroUIProvider import and a test suite verifying NumberInput inherits labelPlacement from provider and that an explicit labelPlacement prop overrides the context.
Hook Implementation
packages/components/number-input/src/use-number-input.ts
Threads labelPlacement into the numberInput variant props and includes labelPlacement in the memoized slots dependency array so slot classes recompute when placement changes.

Sequence Diagram(s)

sequenceDiagram
    participant App as App
    participant Provider as HeroUIProvider
    participant NumberInput as NumberInput
    participant Hook as useNumberInput
    participant Variant as variant(numberInput)

    App->>Provider: Render with labelPlacement="outside"
    Provider->>NumberInput: provide context
    NumberInput->>Hook: call useNumberInput(props)
    activate Hook
    Hook->>Hook: read labelPlacement from context or props
    Hook->>Variant: pass labelPlacement into variant props
    Variant->>Hook: return slot props/classes reflecting placement
    Hook-->>NumberInput: return slots
    deactivate Hook
    NumberInput->>App: render with label positioned "outside"
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas to focus during review:
    • Ensure labelPlacement is correctly read from context and overridden by explicit prop.
    • Verify labelPlacement added to memo dependency array doesn't cause unnecessary re-renders.
    • Confirm tests cover both inheritance and override scenarios.

Possibly related PRs

Suggested reviewers

  • jrgarciadev

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix(number-input): include labelPlacement in dependency array" is clear and specific, accurately describing a key technical change made in the use-number-input.ts file. The title references a real and important part of the implementation—adding labelPlacement to the memoized dependencies—which ensures the component reacts when the provider value changes. While the title emphasizes the technical implementation detail rather than the user-facing benefit (inheriting labelPlacement from HeroUIProvider), it remains directly related to the main objective and is sufficiently specific for a developer scanning the commit history to understand the primary code change.
Linked Issues Check ✅ Passed The changes directly address the primary objective from issue #5845: enabling NumberInput to inherit the labelPlacement value from HeroUIProvider while allowing component-level props to override it. The implementation achieves this by passing labelPlacement into the numberInput() variant props and including it in the useMemo dependency array, ensuring reactive updates when the provider context changes. The added test suite verifies both inheritance behavior and prop override behavior, confirming the fix meets the requirement to match Input component behavior. The changeset file documents this as a feature aligned with issue #5845.
Out of Scope Changes Check ✅ Passed All changes in this PR are directly scoped to addressing issue #5845. The three modified files are: a changeset file documenting the feature, test additions verifying the inheritance and override behavior, and the implementation in use-number-input.ts that enables labelPlacement propagation from HeroUIProvider. Each change is necessary and relevant to the stated objective of making NumberInput inherit labelPlacement from the provider while respecting explicit component props. No unrelated modifications, refactoring, or tangential changes were detected.
Description Check ✅ Passed The PR description comprehensively follows the required template structure, including all key sections: "Closes #5845", a clear description with context and before/after screenshots, current behavior vs. new behavior sections, confirmation that this is not a breaking change, and additional technical information. The description effectively explains both the problem (NumberInput not respecting the HeroUIProvider's labelPlacement setting) and the solution (passing labelPlacement to the variant and including it in memoization dependencies). The level of detail, visual documentation, and structured explanation makes it easy for reviewers to understand the intent and impact of the changes.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent 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 46b5ff6 and b595ea7.

📒 Files selected for processing (1)
  • .changeset/brave-laws-enjoy.md (1 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: ESLint
  • GitHub Check: TypeScript
  • GitHub Check: Build
  • GitHub Check: Continuous Release
🔇 Additional comments (1)
.changeset/brave-laws-enjoy.md (1)

1-5: Changeset format and content look appropriate.

The changeset correctly documents the feature with proper YAML frontmatter and a clear, concise description referencing issue #5845. The patch bump is reasonable for this change.

One minor clarification: The PR description frames this as fixing a bug (NumberInput not respecting the provider's labelPlacement setting), whereas the changeset describes it as a feature ("allow inheriting"). Consider whether this should be categorized as a patch (bug fix) or minor (feature addition) based on your semver conventions. Typically, extending component functionality to inherit from provider context could warrant minor, but patch is reasonable if you consider this a behavioral correction rather than a new capability.


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.

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/components/number-input/src/use-number-input.ts (1)

232-249: hasStartContent in dependency array is likely redundant and can be removed.

hasStartContent is used for rendering logic (data attributes and label placement) but is not a variant key for the numberInput theme function. Since the variant function ignores this property, the memoized slots result is identical regardless of hasStartContent's value. Including it in the dependency array causes unnecessary recomputation without changing the output.

Suggested fix: Remove hasStartContent from the dependency array at line 246.

[
  objectToDeps(variantProps),
  isInvalid,
  labelPlacement,
  isClearable,
  disableAnimation,
]
🧹 Nitpick comments (1)
packages/components/number-input/__tests__/number-input.test.tsx (1)

685-711: Good test coverage for the provider inheritance behavior.

The test suite properly verifies:

  1. NumberInput inherits labelPlacement from HeroUIProvider context
  2. Explicit labelPlacement prop overrides provider context

Both scenarios are essential for validating the fix.

Minor note on test brittleness: The tests rely on CSS class pattern matching (/translate-y.*100%/) to verify label placement. While practical for styling components, this approach is brittle and may break if theme implementation changes. Consider documenting this dependency or, if feasible, testing via other means (e.g., computed styles or data attributes).

📜 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 27fec2d and 46b5ff6.

📒 Files selected for processing (3)
  • .changeset/brave-laws-enjoy.md (1 hunks)
  • packages/components/number-input/__tests__/number-input.test.tsx (2 hunks)
  • packages/components/number-input/src/use-number-input.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/components/number-input/__tests__/number-input.test.tsx (1)
packages/components/number-input/src/index.ts (1)
  • NumberInput (10-10)
packages/components/number-input/src/use-number-input.ts (1)
packages/utilities/shared-utils/src/common/functions.ts (1)
  • objectToDeps (149-159)
⏰ 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: Continuous Release
  • GitHub Check: Prettier
  • GitHub Check: TypeScript
  • GitHub Check: ESLint
  • GitHub Check: Build
🔇 Additional comments (1)
.changeset/brave-laws-enjoy.md (1)

1-5: LGTM! Changeset correctly documents the patch.

The changeset appropriately categorizes this as a patch-level change (bug fix/enhancement without breaking changes) and clearly describes the new capability.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Nov 2, 2025

Open in StackBlitz

@heroui/accordion

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

@heroui/alert

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

@heroui/autocomplete

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

@heroui/avatar

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

@heroui/badge

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

@heroui/breadcrumbs

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

@heroui/button

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

@heroui/calendar

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

@heroui/card

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

@heroui/checkbox

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

@heroui/chip

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

@heroui/code

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

@heroui/date-input

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

@heroui/date-picker

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

@heroui/divider

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

@heroui/drawer

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

@heroui/dropdown

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

@heroui/form

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

@heroui/image

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

@heroui/input

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

@heroui/input-otp

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

@heroui/kbd

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

@heroui/link

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

@heroui/listbox

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

@heroui/menu

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

@heroui/modal

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

@heroui/navbar

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

@heroui/number-input

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

@heroui/pagination

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

@heroui/popover

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

@heroui/progress

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

@heroui/radio

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

@heroui/ripple

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

@heroui/scroll-shadow

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

@heroui/select

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

@heroui/skeleton

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

@heroui/slider

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

@heroui/snippet

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

@heroui/spacer

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

@heroui/spinner

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

@heroui/switch

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

@heroui/table

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

@heroui/tabs

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

@heroui/toast

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

@heroui/tooltip

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

@heroui/user

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

@heroui/react

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

@heroui/system

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

@heroui/system-rsc

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

@heroui/theme

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

@heroui/use-aria-accordion

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

@heroui/use-aria-accordion-item

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

@heroui/use-aria-button

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

@heroui/use-aria-link

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

@heroui/use-aria-modal-overlay

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

@heroui/use-aria-multiselect

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

@heroui/use-aria-overlay

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

@heroui/use-callback-ref

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

@heroui/use-clipboard

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

@heroui/use-data-scroll-overflow

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

@heroui/use-disclosure

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

@heroui/use-draggable

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

@heroui/use-form-reset

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

@heroui/use-image

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

@heroui/use-infinite-scroll

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

@heroui/use-intersection-observer

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

@heroui/use-is-mobile

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

@heroui/use-is-mounted

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

@heroui/use-measure

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

@heroui/use-pagination

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

@heroui/use-real-shape

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

@heroui/use-ref-state

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

@heroui/use-resize

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

@heroui/use-safe-layout-effect

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

@heroui/use-scroll-position

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

@heroui/use-ssr

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

@heroui/use-theme

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

@heroui/use-update-effect

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

@heroui/use-viewport-size

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

@heroui/aria-utils

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

@heroui/dom-animation

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

@heroui/framer-utils

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

@heroui/react-rsc-utils

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

@heroui/react-utils

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

@heroui/shared-icons

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

@heroui/shared-utils

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

@heroui/stories-utils

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

@heroui/test-utils

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

commit: b595ea7

@wingkwong wingkwong added this to the v2.8.6 milestone Nov 2, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 2, 2025

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

Project Deployment Preview Comments Updated (UTC)
heroui Ready Ready Preview Comment Nov 2, 2025 0:47am
heroui-sb Ready Ready Preview Comment Nov 2, 2025 0:47am

Copy link
Copy Markdown
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

감사합니다

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 doesn't set the label placement provided in HeroUIProvider

2 participants