react-core-ts 2.1.11 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -635,8 +635,11 @@ const DropdownFilterTabs = forwardRef<
635
635
  setIsInitialRender(false);
636
636
  } else {
637
637
  // Only call onChange if selectedItems actually changed
638
+ // Skip onChange if applyTabFilter is provided (onChange will be called on Apply button click)
638
639
  if (!deepEqual(selectedItems, prevSelectedItemsRef.current)) {
639
- onChange(selectedItems);
640
+ if (!applyTabFilter) {
641
+ onChange(selectedItems);
642
+ }
640
643
  prevSelectedItemsRef.current = selectedItems;
641
644
  }
642
645
  }
@@ -647,7 +650,7 @@ const DropdownFilterTabs = forwardRef<
647
650
  });
648
651
  });
649
652
  // eslint-disable-next-line react-hooks/exhaustive-deps
650
- }, [selectedItems]);
653
+ }, [selectedItems, applyTabFilter]);
651
654
 
652
655
  useEffect(() => {
653
656
  // Use double requestAnimationFrame to ensure DOM updates are complete
@@ -989,7 +992,19 @@ const DropdownFilterTabs = forwardRef<
989
992
  setDropOpen(false);
990
993
  setSearchValue('');
991
994
  resetSuggections?.();
992
- applyTabFilter?.(values);
995
+ // Extract selectedItems if it's included in values (from moreOptionTab), otherwise use state
996
+ const itemsToPass = values?.selectedItems || selectedItems;
997
+ // Extract moreOptionValues (exclude selectedItems from values if present)
998
+ const { selectedItems: _, ...moreOptionValues } = values || {};
999
+ const moreOpts = Object.keys(moreOptionValues).length > 0 ? moreOptionValues : values;
1000
+ // When Apply button is used (moreOptionTab), notify parent of moreOption values
1001
+ if (moreOpts !== undefined && moreOpts !== null) {
1002
+ onMoreOptionChange?.(moreOpts);
1003
+ }
1004
+ // Pass all selected items from all tabs to applyTabFilter
1005
+ applyTabFilter?.({ selectedItems: itemsToPass, moreOptionValues: moreOpts });
1006
+ // Clear all selected items after applying
1007
+ setSelectedItems([]);
993
1008
  };
994
1009
 
995
1010
  useEffect(() => {
@@ -1048,13 +1063,19 @@ const DropdownFilterTabs = forwardRef<
1048
1063
  >
1049
1064
  {React.isValidElement(moreOptionTab)
1050
1065
  ? React.cloneElement(moreOptionTab as React.ReactElement<any>, {
1051
- onApply: (values?: any) => handleApplySelected(values),
1066
+ onApply: (values?: any) => {
1067
+ // Include selected tab values along with moreOption values
1068
+ handleApplySelected({
1069
+ ...values,
1070
+ selectedItems: selectedItems
1071
+ });
1072
+ },
1052
1073
  onValueChange: (values?: any) => {
1053
- // Check if values exist and update state
1074
+ // Only update local state for UI (e.g. Apply button visibility)
1075
+ // onMoreOptionChange is called only when Apply button is clicked
1054
1076
  const hasValues = values !== undefined && values !== null &&
1055
1077
  (typeof values === 'object' ? Object.keys(values).length > 0 : true);
1056
1078
  setHasMoreOptionValues(hasValues);
1057
- onMoreOptionChange?.(values);
1058
1079
  },
1059
1080
  } as any)
1060
1081
  : moreOptionTab}