Skip to content

Commit

Permalink
Merge pull request #183 from ynput/develop
Browse files Browse the repository at this point in the history
fix(Dropdown): mixed override show remove icon
  • Loading branch information
Innders authored Sep 4, 2024
2 parents ad7b04c + 4d2e9c7 commit ec7083c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Dropdowns/AssigneeSelect/AssigneeDropdownTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface AssigneeDropdownProps {
fullName?: string
avatarUrl?: string
isSelected?: boolean
isSelectedMixed?: boolean
multiSelect: boolean
onClick?: () => void
size?: number
Expand All @@ -52,6 +53,7 @@ export const AssigneeDropdownTemplate = ({
avatarUrl,
fullName,
isSelected,
isSelectedMixed,
multiSelect,
onClick,
size = 21,
Expand All @@ -77,7 +79,8 @@ export const AssigneeDropdownTemplate = ({
<UserImage src={avatarUrl} fullName={fullName} name={name} size={size} />
{fullName || name}
{!!error && ' (missing)'}
{multiSelect && isSelected && <Icon icon={'close'} className="remove" />}
{}
{multiSelect && (isSelected || isSelectedMixed) && <Icon icon={'close'} className="remove" />}
</RowStyled>
)
}
3 changes: 2 additions & 1 deletion src/Dropdowns/AssigneeSelect/AssigneeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ export const AssigneeSelect = forwardRef<DropdownRef, AssigneeSelectProps>(
options={sortedOptions}
dataKey={'name'}
disabled={disabled}
itemTemplate={(ops, isActive, isSelected) => (
itemTemplate={(ops, _isActive, isSelected, _index, selectedMixed) => (
<AssigneeDropdownTemplate
{...ops}
isSelected={isSelected}
isSelectedMixed={selectedMixed.includes(ops.name)}
selectAll={props.onSelectAll && selectAllKey}
allSelected={!!(isAllSelected && props.onSelectAll)}
multiSelect={multiSelect}
Expand Down
2 changes: 1 addition & 1 deletion src/Dropdowns/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ export const Dropdown = forwardRef<DropdownRef, DropdownProps>(
{option.icon && <Icon icon={option.icon} />}
<span>{option[labelKey] || option[dataKey]}</span>
{multiSelect &&
selected?.includes(option[dataKey]) &&
[...selected, ...mixedSelected]?.includes(option[dataKey]) &&
selected.length > minSelected && (
<Icon icon={'close'} className="remove" />
)}
Expand Down

0 comments on commit ec7083c

Please sign in to comment.