Skip to content

Commit 966469c

Browse files
committed
Update react-window to major version 2
Finds use in most dropdowns
1 parent 3c78ad0 commit 966469c

File tree

3 files changed

+50
-46
lines changed

3 files changed

+50
-46
lines changed

package-lock.json

Lines changed: 25 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"react-router": "^7.9.5",
3737
"react-select": "^5.10.2",
3838
"react-textarea-autosize": "^8.5.9",
39-
"react-window": "^1.8.11",
39+
"react-window": "^2.2.3",
4040
"redux": "^5.0.1",
4141
"redux-persist": "^6.0.0",
4242
"redux-thunk": "^3.1.0",
@@ -67,7 +67,6 @@
6767
"@types/lodash": "^4.17.20",
6868
"@types/node": "^24.9.2",
6969
"@types/react-dom": "^19.2.2",
70-
"@types/react-window": "^1.8.8",
7170
"@types/uuid": "^10.0.0",
7271
"@vitejs/plugin-react-swc": "^4.2.0",
7372
"eslint": "^9.39.0",

src/components/shared/DropDown.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { GroupBase, MenuListProps, Props, SelectInstance } from "react-select";
88
import { isJson } from "../../utils/utils";
99
import { ParseKeys } from "i18next";
10-
import { FixedSizeList, ListChildComponentProps } from "react-window";
10+
import { List, RowComponentProps } from "react-window";
1111
import AsyncSelect from "react-select/async";
1212
import AsyncCreatableSelect from "react-select/async-creatable";
1313

@@ -140,23 +140,36 @@ const DropDown = <T, >({
140140
const MenuList = (props: MenuListProps<DropDownOption, false>) => {
141141
const { children, maxHeight } = props;
142142

143-
console.log("Menu List render");
144-
145143
return Array.isArray(children) ? (
146144
<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 }}
151154
overscanCount={4}
152-
width="100%"
153-
>
154-
{({ index, style }: ListChildComponentProps) => <div style={{ ...style }}>{children[index]}</div>}
155-
</FixedSizeList>
155+
/>
156156
</div>
157157
) : null;
158158
};
159159

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+
160173
const filterOptions = (inputValue: string) => {
161174
if (options) {
162175
return options.filter(option =>

0 commit comments

Comments
 (0)