geido commented on code in PR #33054:
URL: https://github.com/apache/superset/pull/33054#discussion_r2037507437


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControl.tsx:
##########
@@ -151,20 +169,21 @@ const HorizontalOverflowFormItem = VerticalFormItem;
 const useFilterControlDisplay = (
   orientation: FilterBarOrientation,
   overflow: boolean,
+  showExcludeSelection: boolean,
 ) =>
   useMemo(() => {
     if (orientation === FilterBarOrientation.Horizontal) {
       if (overflow) {
         return {
           FilterControlContainer: HorizontalOverflowFilterControlContainer,
-          FormItem: HorizontalOverflowFormItem,
+          FormItem : HorizontalOverflowFormItem,
           FilterControlTitleBox: HorizontalOverflowFilterControlTitleBox,
           FilterControlTitle: HorizontalOverflowFilterControlTitle,
         };
       }
       return {
         FilterControlContainer: HorizontalFilterControlContainer,
-        FormItem: HorizontalFormItem,
+        FormItem: (props: any) => <HorizontalFormItem {...props} 
showExcludeSelection={showExcludeSelection} />,

Review Comment:
   Is there any reasons to pass showExcludeSelection explicitly? It seems this 
isn't necessary for all other settings, what makes this special?



##########
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx:
##########
@@ -322,10 +383,35 @@ export default function PluginFilterSelect(props: 
PluginFilterSelectProps) {
           loading={isRefreshing}
           oneLine={filterBarOrientation === FilterBarOrientation.Horizontal}
           invertSelection={inverseSelection}
+          showExcludeSelection={showExcludeSelection}
           options={options}
           sortComparator={sortComparator}
           onDropdownVisibleChange={setFilterActive}
         />
+        {showExcludeSelection && (
+          <CheckBoxControlWrapper 
+            className='exclude-filter' 
+            onClick={() => handleExcludeCheckboxChange(!excludeFilterValues)}
+            data-test="exclude-filter-wrapper"
+          >
+            <Checkbox
+              dataTestAttribute="exclude-filter-checkbox"
+              checked={excludeFilterValues}
+              onChange={handleExcludeCheckboxChange}
+            />
+            <span data-test="exclude-filter-label">
+              {filterBarOrientation === FilterBarOrientation.Horizontal ? 
t('Exclude Values')  : t('Exclude Filter Values')}
+            </span>
+            <Tooltip

Review Comment:
   I think the `IconTooltip` could work here?



##########
superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx:
##########
@@ -71,15 +85,17 @@ describe('SelectFilterPlugin', () => {
   const setDataMask = jest.fn();
   const getWrapper = (props = {}) =>
     render(
-      // @ts-ignore
-      <SelectFilterPlugin
-        // @ts-ignore
-        {...transformProps({
-          ...selectMultipleProps,
-          formData: { ...selectMultipleProps.formData, ...props },
-        })}
-        setDataMask={setDataMask}
-      />,
+      <Provider store={store}>

Review Comment:
   I don't think you need to pass the provider directly here? You can use the 
`useRedux` prop



##########
superset-frontend/src/components/DropdownContainer/index.tsx:
##########
@@ -179,6 +179,39 @@ const DropdownContainer = forwardRef(
       [items, overflowingIndex],
     );
 
+    useEffect(() => {
+      const container = current?.children.item(0);
+      if (!container) return;
+
+      const childrenArray = Array.from(container.children);
+
+      const resizeObserver = new ResizeObserver(() => {
+        recalculateItemWidths();
+      });
+
+      childrenArray.forEach(child => resizeObserver.observe(child));
+
+      return () => {
+        childrenArray.forEach(child => resizeObserver.unobserve(child));
+        resizeObserver.disconnect();
+      };
+    }, [current, items.length]);
+
+    // callback to update item widths so that the useLayoutEffect runs whenever
+    // width of any of the child changes
+    const recalculateItemWidths = () => {
+      const container = current?.children.item(0);
+      if (container) {
+        const { children } = container;
+        const childrenArray = Array.from(children);
+
+        const currentWidths = childrenArray.map(child => 
child.getBoundingClientRect().width);
+
+        // Update state with new widths
+        setItemsWidth(currentWidths);
+      }
+    };
+

Review Comment:
   I am curious as of why all of this logic came into existence? What is this 
trying to solve?



-- 
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