Parcourir la source

Fix filter being cleared before click event dispatches

jnfrati il y a 4 ans
Parent
commit
7a2703fad6
1 fichiers modifiés avec 8 ajouts et 25 suppressions
  1. 8 25
      dashboard/src/components/SearchSelector.tsx

+ 8 - 25
dashboard/src/components/SearchSelector.tsx

@@ -35,6 +35,7 @@ const SearchSelector = ({
   const handleOptionClick = (e: any, option: any) => {
     setIsExpanded(false);
     onSelect(option);
+    setFilter("");
   };
 
   const getLabel = (option: any) => {
@@ -83,12 +84,12 @@ const SearchSelector = ({
             <Dropdown dropdownMaxHeight={dropdownMaxHeight}>
               {!filteredOptions.length ? (
                 <>
-                { !renderAddButton ? (
-                  <DropdownLabel>
-                    {noOptionsText || "No options available for this filter"}
-                  </DropdownLabel>
+                  {!renderAddButton ? (
+                    <DropdownLabel>
+                      {noOptionsText || "No options available for this filter"}
+                    </DropdownLabel>
                   ) : (
-                    <div 
+                    <div
                       onMouseDown={(e) => {
                         e.stopPropagation();
                         e.preventDefault();
@@ -97,13 +98,12 @@ const SearchSelector = ({
                     >
                       {renderAddButton()}
                     </div>
-                  )
-                }
+                  )}
                 </>
               ) : (
                 <>
                   {renderAddButton && (
-                    <div 
+                    <div
                       onMouseDown={(e) => {
                         e.stopPropagation();
                         e.preventDefault();
@@ -122,7 +122,6 @@ const SearchSelector = ({
                       onMouseDown={(e) => {
                         e.stopPropagation();
                         e.preventDefault();
-                        setFilter("");
                       }}
                       onClick={(e) => handleOptionClick(e, option)}
                     >
@@ -227,19 +226,3 @@ const Option = styled.div`
     background: #ffffff22;
   }
 `;
-
-const Icon = styled.div`
-  height: 20px;
-  width: 30px;
-  margin-left: -5px;
-  margin-right: 10px;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  overflow: visible;
-
-  > img {
-    height: 18px;
-    width: auto;
-  }
-`;