diff --git a/.changeset/polite-ravens-hide.md b/.changeset/polite-ravens-hide.md new file mode 100644 index 0000000000..94ea4fa7ce --- /dev/null +++ b/.changeset/polite-ravens-hide.md @@ -0,0 +1,5 @@ +--- +"@nextui-org/input": patch +--- + +Fix #2268, when using a number input and with a 0 for the initial value, the label (default or labelPlacement='inside') does not animate to the correct position. Even when the user is setting the value to 0, the label does not alter its state unless a number other than 0 is inputted. diff --git a/packages/components/input/src/use-input.ts b/packages/components/input/src/use-input.ts index f2e1301f66..c523a1350d 100644 --- a/packages/components/input/src/use-input.ts +++ b/packages/components/input/src/use-input.ts @@ -6,7 +6,7 @@ import {useFocusRing} from "@react-aria/focus"; import {input} from "@nextui-org/theme"; import {useDOMRef, filterDOMProps} from "@nextui-org/react-utils"; import {useFocusWithin, useHover, usePress} from "@react-aria/interactions"; -import {clsx, dataAttr, safeAriaLabel} from "@nextui-org/shared-utils"; +import {clsx, dataAttr, isEmpty, safeAriaLabel} from "@nextui-org/shared-utils"; import {useControlledState} from "@react-stately/utils"; import {useMemo, Ref, useCallback, useState} from "react"; import {chain, mergeProps} from "@react-aria/utils"; @@ -124,7 +124,7 @@ export function useInput {