Skip to content

Commit

Permalink
Merge pull request #182 from ynput/develop
Browse files Browse the repository at this point in the history
Release: dropdown remove icon for anything selected
  • Loading branch information
Innders authored Sep 4, 2024
2 parents 6c0f40e + 09c35f2 commit ad7b04c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
13 changes: 2 additions & 11 deletions src/Dropdowns/AssigneeSelect/AssigneeDropdownTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled, { css } from 'styled-components'
import styled from 'styled-components'
import { UserImage } from '../../User/UserImage'
import { Icon } from '../../Icon'
import clsx from 'clsx'
Expand Down Expand Up @@ -39,10 +39,7 @@ export interface AssigneeDropdownProps {
fullName?: string
avatarUrl?: string
isSelected?: boolean
isMultiple: boolean
mixedSelected: string[]
multiSelect: boolean
multipleOverride: boolean
onClick?: () => void
size?: number
selectAll?: string | boolean
Expand All @@ -55,10 +52,7 @@ export const AssigneeDropdownTemplate = ({
avatarUrl,
fullName,
isSelected,
isMultiple,
mixedSelected,
multiSelect,
multipleOverride,
onClick,
size = 21,
selectAll,
Expand All @@ -83,10 +77,7 @@ export const AssigneeDropdownTemplate = ({
<UserImage src={avatarUrl} fullName={fullName} name={name} size={size} />
{fullName || name}
{!!error && ' (missing)'}
{multiSelect &&
isMultiple &&
!multipleOverride &&
(mixedSelected?.includes(name) || isSelected) && <Icon icon={'close'} className="remove" />}
{multiSelect && isSelected && <Icon icon={'close'} className="remove" />}
</RowStyled>
)
}
5 changes: 1 addition & 4 deletions src/Dropdowns/AssigneeSelect/AssigneeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,13 @@ export const AssigneeSelect = forwardRef<DropdownRef, AssigneeSelectProps>(
options={sortedOptions}
dataKey={'name'}
disabled={disabled}
itemTemplate={(ops, isActive, isSelected, index, mixedSelected) => (
itemTemplate={(ops, isActive, isSelected) => (
<AssigneeDropdownTemplate
{...ops}
isSelected={isSelected}
selectAll={props.onSelectAll && selectAllKey}
allSelected={!!(isAllSelected && props.onSelectAll)}
mixedSelected={mixedSelected}
multiSelect={multiSelect}
multipleOverride={multipleOverride}
isMultiple={isMultiple}
/>
)}
onChange={(added, removed) => onChange && onChange(added, removed)}
Expand Down
6 changes: 2 additions & 4 deletions src/Dropdowns/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,8 @@ export const Dropdown = forwardRef<DropdownRef, DropdownProps>(
{option.icon && <Icon icon={option.icon} />}
<span>{option[labelKey] || option[dataKey]}</span>
{multiSelect &&
isMultiple &&
!multipleOverride &&
option[dataKey] !== selectAllKey &&
!![...mixedSelected, ...selected]?.includes(option[dataKey]) && (
selected?.includes(option[dataKey]) &&
selected.length > minSelected && (
<Icon icon={'close'} className="remove" />
)}
</Styled.DefaultItem>
Expand Down

0 comments on commit ad7b04c

Please sign in to comment.