Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface InputSkillSelectorProps {
readonly theme?: InputMultiselectThemes
readonly useWrapper?: boolean
readonly dropdownIcon?: ReactNode
readonly additionalPlaceholder?: string
}

const InputSkillSelector: FC<InputSkillSelectorProps> = props => (
Expand All @@ -52,6 +53,7 @@ const InputSkillSelector: FC<InputSkillSelectorProps> = props => (
theme={props.theme}
useWrapper={props.useWrapper}
dropdownIcon={props.dropdownIcon}
additionalPlaceholder={props.additionalPlaceholder}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
}
}

.additionalPlaceholder {
color: $black-60;
width: 0;
pointer-events: none;
white-space: nowrap;
}

.multiselect .ms {
display: block;

Expand Down Expand Up @@ -77,6 +84,7 @@
grid-template-columns: 0 min-content;
padding: 0;
visibility: visible;
order: 999;
}

&:global(__multi-value) {
Expand Down Expand Up @@ -164,6 +172,9 @@
color: $tc-white;
}
}
&:global(__control--is-focused) .additionalPlaceholder {
display: none;
}
}

.theme-clear.multiselect .ms {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface InputMultiselectProps {
readonly onFetchOptions?: (query: string) => Promise<InputMultiselectOption[]>
readonly options?: ReadonlyArray<InputMultiselectOption>
readonly placeholder?: string
readonly additionalPlaceholder?: string
readonly tabIndex?: number
readonly theme?: InputMultiselectThemes
readonly useWrapper?: boolean
Expand All @@ -61,6 +62,18 @@ const dropdownIndicator = (dropdownIcon: ReactNode): FC => (props: any) => (
</components.DropdownIndicator>
)

// eslint-disable-next-line react/function-component-definition
const valueContainer = (additionalPlaceholder: string): FC => (props: any) => (
<components.ValueContainer {...props}>
{props.children}
{props.hasValue && additionalPlaceholder && (
<span className={classNames('body-small', styles.additionalPlaceholder)}>
{additionalPlaceholder}
</span>
)}
</components.ValueContainer>
)

const InputMultiselect: FC<InputMultiselectProps> = (props: InputMultiselectProps) => {

function handleOnChange(options: readonly InputMultiselectOption[]): void {
Expand Down Expand Up @@ -97,7 +110,11 @@ const InputMultiselect: FC<InputMultiselectProps> = (props: InputMultiselectProp
isLoading={props.loading}
isOptionDisabled={isOptionDisabled}
isSearchable={!isOptionDisabled()}
components={{ DropdownIndicator: dropdownIndicator(props.dropdownIcon), MultiValueRemove }}
components={{
DropdownIndicator: dropdownIndicator(props.dropdownIcon),
MultiValueRemove,
ValueContainer: valueContainer(props.additionalPlaceholder ?? 'Add more...'),
}}
value={props.value}
openMenuOnClick={false}
/>
Expand Down