Skip to content

Commit

Permalink
refactor: ♻️ cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
harshzalavadiya committed Jun 8, 2022
1 parent 0db9aaa commit 007c6a2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/select-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* user selects the component. It encapsulates the search filter, the
* Select-all item, and the list of options.
*/
import React, {
import React, {
useCallback,
useEffect,
useMemo,
Expand Down Expand Up @@ -177,10 +177,10 @@ const SelectPanel = () => {
const creationRef: any = useRef();
useKey([KEY.ENTER], handleOnCreateOption, { target: creationRef });

const canCreatableAppear =
const showCratable =
isCreatable &&
searchText &&
!filteredOptions.some((e) => e.value + "" === searchText);
!filteredOptions.some((e) => e?.value === searchText);

return (
<div className="select-panel" role="listbox" ref={listRef}>
Expand Down Expand Up @@ -227,11 +227,7 @@ const SelectPanel = () => {
options={filteredOptions}
onClick={(_e, index) => handleItemClicked(index)}
/>
) : canCreatableAppear ? null : (
<li className="no-options">{t("noOptions")}</li>
)}

{canCreatableAppear && (
) : showCratable ? (
<li
onClick={handleOnCreateOption}
className="select-item creatable"
Expand All @@ -240,6 +236,8 @@ const SelectPanel = () => {
>
{`${t("create")} "${searchText}"`}
</li>
) : (
<li className="no-options">{t("noOptions")}</li>
)}
</ul>
</div>
Expand Down

0 comments on commit 007c6a2

Please sign in to comment.