fix(input): label placement outside when label is missing (#2028)

This commit is contained in:
Junior Garcia 2023-11-24 09:20:39 -03:00 committed by GitHub
parent 088af8b6df
commit 0ba165f0fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -0,0 +1,6 @@
---
"@nextui-org/select": patch
"@nextui-org/input": patch
---
Fix #1979 labelPlacement is outside when not having a label for input, autocomplete and select components.

View File

@ -135,12 +135,9 @@ export function useInput<T extends HTMLInputElement | HTMLTextAreaElement = HTML
const handleClear = useCallback(() => {
setInputValue("");
if (domRef.current) {
domRef.current.value = "";
domRef.current.focus();
}
onClear?.();
}, [domRef, setInputValue, onClear]);
domRef.current?.focus();
}, [setInputValue, onClear]);
const {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(
{
@ -211,9 +208,10 @@ export function useInput<T extends HTMLInputElement | HTMLTextAreaElement = HTML
input({
...variantProps,
isInvalid,
labelPlacement,
isClearable,
}),
[...Object.values(variantProps), isInvalid, isClearable, hasStartContent],
[...Object.values(variantProps), isInvalid, labelPlacement, isClearable, hasStartContent],
);
const getBaseProps: PropGetter = useCallback(

View File

@ -280,9 +280,10 @@ export function useSelect<T extends object>(originalProps: UseSelectProps<T>) {
select({
...variantProps,
isInvalid,
labelPlacement,
className,
}),
[...Object.values(variantProps), isInvalid, className],
[...Object.values(variantProps), isInvalid, labelPlacement, className],
);
// scroll the listbox to the selected item