Skip to content

Commit b3612a0

Browse files
authored
Merge pull request #24 from BeeInventor/fix/dropdown
feat: dropdown selection list of id selected
2 parents 8e71355 + fdb4a5d commit b3612a0

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

src/components/Dropdown/Dropdown.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ Selected.args = {
7373
selectedId: 'A004',
7474
};
7575

76+
export const Selection: Story<DropDownProps> = Template.bind({});
77+
78+
Selection.args = {
79+
...Default.args,
80+
selectedId: 'A004',
81+
selectionId: 'A003',
82+
};
83+
7684
export const WithDialog: Story<DropDownProps> = (args) => {
7785
const [isOpen, setIsOpen] = useState(false);
7886
return (

src/components/Dropdown/Dropdown.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const Dropdown: React.VFC<DropDownProps> = (props) => {
6666
disabled,
6767
onSelect,
6868
popperProps,
69+
selectionId,
6970
mode = 'light',
7071
...otherProps
7172
} = props;
@@ -107,19 +108,21 @@ const Dropdown: React.VFC<DropDownProps> = (props) => {
107108
onSelect(item.value, item);
108109
};
109110

110-
const items = list.map((item) => (
111-
<Item
112-
key={`dropdown-item-${item.id}`}
113-
className="Dropdown-item"
114-
onClick={() => handleOnClick(item)}
115-
{...itemProps}
116-
>
117-
<Icon className="Dropdown-icon">
118-
{selectedItem?.id === item.id && <img src={CheckSvg} />}
119-
</Icon>
120-
{item.name}
121-
</Item>
122-
));
111+
const items = list
112+
.filter((item) => item.id !== selectionId)
113+
.map((item) => (
114+
<Item
115+
key={`dropdown-item-${item.id}`}
116+
className="Dropdown-item"
117+
onClick={() => handleOnClick(item)}
118+
{...itemProps}
119+
>
120+
<Icon className="Dropdown-icon">
121+
{selectedItem?.id === item.id && <img src={CheckSvg} />}
122+
</Icon>
123+
{item.name}
124+
</Item>
125+
));
123126

124127
return (
125128
<>

src/components/Dropdown/Dropdown.type.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ export interface DropDownProps extends Omit<BoxProps, 'onSelect'> {
3737
*/
3838
popperProps?: Omit<PopperProps, 'open' | 'anchorEl'>;
3939
mode?: 'dark' | 'light';
40+
/**
41+
* filter the list out of this id
42+
*/
43+
selectionId?: string;
4044
}

0 commit comments

Comments
 (0)