diff --git a/packages/core/src/components/common/autocomplete/Autocomplete.css b/packages/core/src/components/common/autocomplete/Autocomplete.css index 6e549e51..aff0aa11 100644 --- a/packages/core/src/components/common/autocomplete/Autocomplete.css +++ b/packages/core/src/components/common/autocomplete/Autocomplete.css @@ -1,6 +1,10 @@ .CMS_Autocomplete_root { @apply relative - w-full; + w-full + flex + items-center + gap-2 + pr-2; &.CMS_Autocomplete_disabled { & .CMS_Autocomplete_input { @@ -15,13 +19,19 @@ } } +.CMS_Autocomplete_input-wrapper { + @apply flex-grow + flex + flex-wrap + min-w-0; +} + .CMS_Autocomplete_input { @apply w-full bg-transparent border-none py-2 pl-3 - pr-10 text-sm leading-5 focus:ring-0 @@ -33,13 +43,10 @@ } .CMS_Autocomplete_button-wrapper { - @apply absolute - inset-y-0 - right-0 - flex + @apply flex items-center - pr-2 - gap-1; + gap-1 + flex-shrink-0; } .CMS_Autocomplete_button { diff --git a/packages/core/src/components/common/autocomplete/Autocomplete.tsx b/packages/core/src/components/common/autocomplete/Autocomplete.tsx index 7f25fa6c..bdf98aaa 100644 --- a/packages/core/src/components/common/autocomplete/Autocomplete.tsx +++ b/packages/core/src/components/common/autocomplete/Autocomplete.tsx @@ -20,6 +20,7 @@ export const classes = generateClassNames('Autocomplete', [ 'root', 'focused', 'disabled', + 'input-wrapper', 'input', 'button-wrapper', 'button', @@ -55,6 +56,7 @@ export interface AutocompleteProps { disabled?: boolean; required?: boolean; inputRef?: Ref; + endAdornment?: ReactNode; displayValue: (item: string | string[] | null) => string; onQuery: (query: string) => void; onChange: (value: string | string[] | undefined) => void; @@ -64,9 +66,10 @@ const Autocomplete = ({ label, value, options, - inputRef, disabled, required, + inputRef, + endAdornment, onChange, onQuery, }: AutocompleteProps) => { @@ -187,14 +190,17 @@ const Autocomplete = ({ )} data-testid="autocomplete" > - {label} - +
+ {label} + +
+ {endAdornment} > > - {Array.isArray(selectedValue) && selectedValue.length > 0 ? ( -
- {selectedValue.map(selectValue => { - const option = uniqueOptionsByValue[selectValue]; - return ( - - {option?.label ?? selectValue} - - ); - })} -
- ) : null} - {loading ? ( - - ) : null} - + Array.isArray(selectedValue) && selectedValue.length > 0 ? ( +
+ {selectedValue.map(selectValue => { + const option = uniqueOptionsByValue[selectValue]; + return ( + + {option?.label ?? selectValue} + + ); + })} +
+ ) : null } inputRef={ref} value={selectedValue} @@ -398,6 +388,16 @@ const RelationControl: FC> return option.label; }} + endAdornment={ + loading ? ( + + ) : null + } onQuery={filterOptions} onChange={handleChange} /> diff --git a/tailwind.base.config.js b/tailwind.base.config.js index 7c31641b..2e1111af 100644 --- a/tailwind.base.config.js +++ b/tailwind.base.config.js @@ -32,7 +32,6 @@ module.exports = { "breadcrumb-title": "calc(100vw * .4)", "collection-header": "calc(100% - 32px)", "date-widget": "calc(100% - 58px)", - "relation-widget-label": "calc(100% - 32px)", "select-widget-label": "calc(100% - 12px)", }, maxWidth: {