michael-s-molina commented on a change in pull request #16393:
URL: https://github.com/apache/superset/pull/16393#discussion_r701357194



##########
File path: superset-frontend/src/components/ListView/Filters/Select.tsx
##########
@@ -75,78 +61,53 @@ function SelectFilter({
   }
 
   const [selectedOption, setSelectedOption] = useState(initialOption);
-  const onChange = (selected: SelectOption | null) => {
-    if (selected === null) return;
+  const onChange = (selected: SelectOption) => {
     onSelect(
       selected.value === CLEAR_SELECT_FILTER_VALUE ? undefined : 
selected.value,
     );
     setSelectedOption(selected);
   };
 
-  const fetchAndFormatSelects = async (
-    inputValue: string,
-    loadedOptions: SelectOption[],
-    { page }: { page: number },
-  ) => {
-    // only include clear filter when filter value does not exist
-    let result = inputValue || page > 0 ? [] : [clearFilterSelect];
-    let hasMore = paginate;
-    if (fetchSelects) {
-      const selectValues = await fetchSelects(inputValue, page);
-      // update matching option at initial load
-      if (!selectValues.length) {
-        hasMore = false;
-      }
-      result = [...result, ...selectValues];
+  const fetchAndFormatSelects = useMemo(
+    () => async (inputValue: string, page: number, pageSize: number) => {
+      // only include clear filter when filter value does not exist
+      let result = inputValue || page > 0 ? [] : [clearFilterSelect];
+      if (fetchSelects) {
+        const selectValues = await fetchSelects(inputValue, page, pageSize);
+        const totalCount = selectValues.totalCount + result.length;
+        result = [...result, ...selectValues.data];
 
-      const matchingOption = result.find(x => x.value === initialValue);
+        const matchingOption = result.find(x => x.value === initialValue);
+        if (matchingOption) {
+          setSelectedOption(matchingOption);
+        }
 
-      if (matchingOption) {
-        setSelectedOption(matchingOption);
+        return {
+          data: result,
+          totalCount,
+        };
       }
-    }
-
-    return {
-      options: result,
-      hasMore,
-      additional: {
-        page: page + 1,
-      },
-    };
-  };
+      return {
+        data: [],
+        totalCount: 0,
+      };
+    },
+    [], // eslint-disable-line react-hooks/exhaustive-deps
+  );
 
   return (
     <FilterContainer>
-      <FilterTitle>{Header}:</FilterTitle>
-      {fetchSelects ? (
-        <PaginatedSelect
-          data-test="filters-select"
-          defaultOptions
-          themeConfig={filterSelectTheme}
-          stylesConfig={filterSelectStyles}
-          // @ts-ignore
-          value={selectedOption}
-          // @ts-ignore
-          onChange={onChange}
-          // @ts-ignore
-          loadOptions={fetchAndFormatSelects}
-          placeholder={emptyLabel}
-          clearable={false}
-          additional={{
-            page: 0,
-          }}
-        />
-      ) : (
-        <Select
-          data-test="filters-select"
-          themeConfig={filterSelectTheme}
-          stylesConfig={filterSelectStyles}
-          value={selectedOption}
-          options={options}
-          onChange={onChange}
-          clearable={false}
-        />
-      )}
+      <Select
+        ariaLabel={typeof Header === 'string' ? Header : emptyLabel}

Review comment:
       You're right. I changed it to use the header or the name or a generic 
'Filter'.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to