@@ -4,7 +4,6 @@ import { Fragment, useEffect, useState } from 'react';
4
4
import 'react-dates/initialize' ;
5
5
import 'react-dates/lib/css/_datepicker.css' ;
6
6
import { usePopper } from 'react-popper' ;
7
- import { FixedSizeList as List } from 'react-window' ;
8
7
import { ReactComponent as FormSelectSearchCloseIcon } from '../../assets/images/svg/form-select-search-close-icon.svg' ;
9
8
import { ReactComponent as FormSelectDropdownIcon } from '../../assets/images/svg/form-select-dropdown-icon.svg' ;
10
9
import { ReactComponent as RemoveOptionIcon } from '../../assets/images/svg/remove-option-icon.svg' ;
@@ -108,7 +107,10 @@ const MultiSelectField = ({
108
107
style = { styles [ 'popper' ] }
109
108
{ ...attributes [ 'popper' ] }
110
109
>
111
- < Listbox . Options data-cy = "multi_select_values" className = "absolute z-[1] h-fit max-h-96 w-full overflow-y-auto border bg-white px-[8px] py-[12px] font-lato text-base ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm" >
110
+ < Listbox . Options
111
+ data-cy = "multi_select_values"
112
+ className = "absolute z-[1] h-fit max-h-96 w-full overflow-y-auto border bg-white px-[8px] py-[12px] font-lato text-base ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
113
+ >
112
114
{ optionsData ?. length > 10 ? (
113
115
< div className = "relative mb-4" >
114
116
< input
@@ -130,50 +132,40 @@ const MultiSelectField = ({
130
132
</ div >
131
133
) : null }
132
134
133
- < List
134
- height = {
135
- filteredOptions . length < 10
136
- ? filteredOptions . length * 40
137
- : 300
138
- }
139
- itemCount = { filteredOptions . length }
140
- itemSize = { 40 }
141
- itemData = { filteredOptions }
142
- className = "complete-hidden-scroll-style"
143
- >
144
- { ( { index, style } ) => (
135
+ { /* Replaced the react-window List with a normal map */ }
136
+ < Listbox . Options className = "space-y-2" >
137
+ { filteredOptions . map ( ( option , index ) => (
145
138
< Listbox . Option
146
139
key = { index }
147
- style = { style }
148
140
className = { ( { active } ) =>
149
141
`relative flex cursor-default select-none items-center gap-[12px] p-2 ${
150
142
active ? '' : ''
151
143
} `
152
144
}
153
- value = { filteredOptions [ index ] }
154
- disabled = { filteredOptions [ index ] . unavailable || false }
145
+ value = { option }
146
+ disabled = { option . unavailable || false }
155
147
>
156
148
< span className = "flex items-center" >
157
149
< FormMultiSelectCheckIcon
158
150
className = { `${
159
- value . indexOf ( filteredOptions [ index ] . id ) >= 0
151
+ value . indexOf ( option . id ) >= 0
160
152
? 'text-[#000000]'
161
153
: 'text-[#eff3f4]'
162
154
} `}
163
155
/>
164
156
</ span >
165
157
< span
166
158
className = { `block truncate font-lato ${
167
- filteredOptions [ index ] . unavailable || false
159
+ option . unavailable || false
168
160
? 'opacity-50'
169
161
: 'cursor-pointer'
170
162
} `}
171
163
>
172
- { filteredOptions [ index ] . label }
164
+ { option . label }
173
165
</ span >
174
166
</ Listbox . Option >
175
- ) }
176
- </ List >
167
+ ) ) }
168
+ </ Listbox . Options >
177
169
</ Listbox . Options >
178
170
</ Transition >
179
171
</ div >
@@ -200,7 +192,12 @@ const MultiSelectField = ({
200
192
</ div >
201
193
202
194
{ meta . touched && meta . error ? (
203
- < div data-cy = "error_message" className = "font-lato text-[12px] text-[#cc3300]" > { meta . error } </ div >
195
+ < div
196
+ data-cy = "error_message"
197
+ className = "font-lato text-[12px] text-[#cc3300]"
198
+ >
199
+ { meta . error }
200
+ </ div >
204
201
) : null }
205
202
</ div >
206
203
) ;
0 commit comments