mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	* Add extra undefined check for table filters
* Logic fix..
- Do not return early, this is mistake!
- Correctly handle empty activeFilter state
(cherry picked from commit 7d844e02be)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
			
			
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							edf02cd817
						
					
				
				
					commit
					e89cfd4958
				
			@@ -65,8 +65,13 @@ function FilterAddGroup({
 | 
			
		||||
  availableFilters: TableFilter[];
 | 
			
		||||
}) {
 | 
			
		||||
  const filterOptions: TableFilterChoice[] = useMemo(() => {
 | 
			
		||||
    let activeFilterNames =
 | 
			
		||||
      tableState.activeFilters?.map((flt) => flt.name) ?? [];
 | 
			
		||||
    // List of filter names which are already active on this table
 | 
			
		||||
    let activeFilterNames: string[] = [];
 | 
			
		||||
 | 
			
		||||
    if (tableState.activeFilters && tableState.activeFilters.length > 0) {
 | 
			
		||||
      activeFilterNames =
 | 
			
		||||
        tableState.activeFilters?.map((flt) => flt.name) ?? [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
      availableFilters
 | 
			
		||||
@@ -83,7 +88,7 @@ function FilterAddGroup({
 | 
			
		||||
 | 
			
		||||
  const valueOptions: TableFilterChoice[] = useMemo(() => {
 | 
			
		||||
    // Find the matching filter
 | 
			
		||||
    let filter: TableFilter | undefined = availableFilters.find(
 | 
			
		||||
    let filter: TableFilter | undefined = availableFilters?.find(
 | 
			
		||||
      (flt) => flt.name === selectedFilter
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user