diff --git a/components/auto-complete/auto-complete-item.tsx b/components/auto-complete/auto-complete-item.tsx index a78c315..09edffc 100644 --- a/components/auto-complete/auto-complete-item.tsx +++ b/components/auto-complete/auto-complete-item.tsx @@ -7,6 +7,7 @@ import Ellipsis from '../shared/ellipsis' interface Props { value: string + isLabelOnly?: boolean } const defaultProps = {} @@ -26,6 +27,7 @@ const getSizes = (size: NormalSizes) => { const AutoCompleteItem: React.FC> = ({ value: identValue, children, + isLabelOnly, }) => { const theme = useTheme() const { value, updateValue, size, updateVisible } = useAutoCompleteContext() @@ -37,9 +39,20 @@ const AutoCompleteItem: React.FC> const isActive = useMemo(() => value === identValue, [identValue, value]) const fontSize = useMemo(() => getSizes(size), [size]) + // The 'isLabelOnly' is only used inside the component, + // Automatically adjust width when only label children is included. + const itemHeight = useMemo(() => { + if (isLabelOnly) return `calc(1.688 * ${theme.layout.gap})` + return 'auto' + }, [isLabelOnly, theme.layout.gap]) + return (
- {children} + {isLabelOnly ? ( + {children} + ) : ( + children + )}