Skip to content

Commit 007c6a2

Browse files
refactor: ♻️ cleanup
1 parent 0db9aaa commit 007c6a2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/select-panel/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* user selects the component. It encapsulates the search filter, the
44
* Select-all item, and the list of options.
55
*/
6-
import React, {
6+
import React, {
77
useCallback,
88
useEffect,
99
useMemo,
@@ -177,10 +177,10 @@ const SelectPanel = () => {
177177
const creationRef: any = useRef();
178178
useKey([KEY.ENTER], handleOnCreateOption, { target: creationRef });
179179

180-
const canCreatableAppear =
180+
const showCratable =
181181
isCreatable &&
182182
searchText &&
183-
!filteredOptions.some((e) => e.value + "" === searchText);
183+
!filteredOptions.some((e) => e?.value === searchText);
184184

185185
return (
186186
<div className="select-panel" role="listbox" ref={listRef}>
@@ -227,11 +227,7 @@ const SelectPanel = () => {
227227
options={filteredOptions}
228228
onClick={(_e, index) => handleItemClicked(index)}
229229
/>
230-
) : canCreatableAppear ? null : (
231-
<li className="no-options">{t("noOptions")}</li>
232-
)}
233-
234-
{canCreatableAppear && (
230+
) : showCratable ? (
235231
<li
236232
onClick={handleOnCreateOption}
237233
className="select-item creatable"
@@ -240,6 +236,8 @@ const SelectPanel = () => {
240236
>
241237
{`${t("create")} "${searchText}"`}
242238
</li>
239+
) : (
240+
<li className="no-options">{t("noOptions")}</li>
243241
)}
244242
</ul>
245243
</div>

0 commit comments

Comments
 (0)