This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch all-charts-category-alone
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 79af32848e914cc20740f7531b7b14fb50ce58f0
Author: David Aaron Suddjian <[email protected]>
AuthorDate: Mon Jul 26 17:05:43 2021 -0700

    make onClear optional
---
 .../controls/VizTypeControl/VizTypeGallery.tsx     | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git 
a/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx
 
b/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx
index 834e668..e50df45 100644
--- 
a/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx
+++ 
b/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx
@@ -400,7 +400,7 @@ const Selector: React.FC<{
   icon: JSX.Element;
   isSelected: boolean;
   onClick: (selector: string) => void;
-  onClear: (e: React.MouseEvent) => void;
+  onClear?: (e: React.MouseEvent) => void;
   className?: string;
 }> = ({ selector, icon, isSelected, onClick, onClear, className }) => {
   const btnRef = useRef<HTMLButtonElement>(null);
@@ -429,7 +429,7 @@ const Selector: React.FC<{
     >
       {icon}
       {selector}
-      <CloseOutlined className="cancel" onClick={onClear} />
+      {onClear && <CloseOutlined className="cancel" onClick={onClear} />}
     </SelectorLabel>
   );
 };
@@ -580,14 +580,17 @@ export default function VizTypeGallery(props: 
VizTypeGalleryProps) {
     ],
   );
 
-  const clearSelector = useCallback(e => {
-    e.stopPropagation();
-    if (isSearchFocused) {
-      stopSearching();
-    }
-    // clear current selector and set all charts
-    setActiveSelector(ALL_CHARTS);
-  }, []);
+  const clearSelector = useCallback(
+    e => {
+      e.stopPropagation();
+      if (isSearchFocused) {
+        stopSearching();
+      }
+      // clear current selector and set all charts
+      setActiveSelector(ALL_CHARTS);
+    },
+    [isSearchFocused, stopSearching],
+  );
 
   const sectionMap = useMemo(
     () => ({

Reply via email to