|
7 | 7 | import { GroupBase, MenuListProps, Props, SelectInstance } from "react-select"; |
8 | 8 | import { isJson } from "../../utils/utils"; |
9 | 9 | import { ParseKeys } from "i18next"; |
10 | | -import { FixedSizeList, ListChildComponentProps } from "react-window"; |
| 10 | +import { List, RowComponentProps } from "react-window"; |
11 | 11 | import AsyncSelect from "react-select/async"; |
12 | 12 | import AsyncCreatableSelect from "react-select/async-creatable"; |
13 | 13 |
|
@@ -140,23 +140,36 @@ const DropDown = <T, >({ |
140 | 140 | const MenuList = (props: MenuListProps<DropDownOption, false>) => { |
141 | 141 | const { children, maxHeight } = props; |
142 | 142 |
|
143 | | - console.log("Menu List render"); |
144 | | - |
145 | 143 | return Array.isArray(children) ? ( |
146 | 144 | <div style={{ paddingTop: 4 }}> |
147 | | - <FixedSizeList |
148 | | - height={maxHeight < (children.length * itemHeight) ? maxHeight : children.length * itemHeight} |
149 | | - itemCount={children.length} |
150 | | - itemSize={itemHeight} |
| 145 | + <List |
| 146 | + rowComponent={MenuListRow} |
| 147 | + rowCount={children.length} |
| 148 | + rowHeight={itemHeight} |
| 149 | + style={{ |
| 150 | + height: maxHeight < (children.length * itemHeight) ? maxHeight : children.length * itemHeight, |
| 151 | + width: "100%", |
| 152 | + }} |
| 153 | + rowProps={{ names: children }} |
151 | 154 | overscanCount={4} |
152 | | - width="100%" |
153 | | - > |
154 | | - {({ index, style }: ListChildComponentProps) => <div style={{ ...style }}>{children[index]}</div>} |
155 | | - </FixedSizeList> |
| 155 | + /> |
156 | 156 | </div> |
157 | 157 | ) : null; |
158 | 158 | }; |
159 | 159 |
|
| 160 | + function MenuListRow({ |
| 161 | + index, |
| 162 | + names, |
| 163 | + style, |
| 164 | + }: RowComponentProps<{ |
| 165 | + names: string[]; |
| 166 | + }>) { |
| 167 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access |
| 168 | + const name = names[index]; |
| 169 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
| 170 | + return <div style={style}>{name}</div>; |
| 171 | + } |
| 172 | + |
160 | 173 | const filterOptions = (inputValue: string) => { |
161 | 174 | if (options) { |
162 | 175 | return options.filter(option => |
|
0 commit comments