From 6c6050d0640e2a1691fbaf718eadd68c0fca0319 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 9 Apr 2021 15:24:32 +0300 Subject: [PATCH] custom filter option (#397) --- components/common/MySelect.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/common/MySelect.tsx b/components/common/MySelect.tsx index f8085288a..0f4b8fe84 100644 --- a/components/common/MySelect.tsx +++ b/components/common/MySelect.tsx @@ -45,6 +45,14 @@ const DropdownIndicator = (props: any) => { ); }; +const customFilterOption = (option: any, rawInput: string) => { + const words = rawInput.split(" "); + return words.reduce( + (acc, cur) => acc && option.label.toLowerCase().includes(cur.toLowerCase()), + true + ); +}; + const MySelect: React.FC = ({ options, components, @@ -105,6 +113,7 @@ const MySelect: React.FC = ({ isDisabled={isDisabled} isClearable={isClearable} options={options} + filterOption={customFilterOption} components={ hideMenuBeforeTyping ? {