mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	Prevent single letter words from matching filter suggestions (#14297)
This commit is contained in:
		
							parent
							
								
									6e332bbdf8
								
							
						
					
					
						commit
						de86c37687
					
				@ -7,6 +7,7 @@ import {
 | 
				
			|||||||
  LuChevronUp,
 | 
					  LuChevronUp,
 | 
				
			||||||
  LuTrash2,
 | 
					  LuTrash2,
 | 
				
			||||||
  LuStar,
 | 
					  LuStar,
 | 
				
			||||||
 | 
					  LuSearch,
 | 
				
			||||||
} from "react-icons/lu";
 | 
					} from "react-icons/lu";
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  FilterType,
 | 
					  FilterType,
 | 
				
			||||||
@ -161,8 +162,12 @@ export default function InputWithTags({
 | 
				
			|||||||
        .map((word) => word.trim())
 | 
					        .map((word) => word.trim())
 | 
				
			||||||
        .lastIndexOf(words.filter((word) => word.trim() !== "").pop() || "");
 | 
					        .lastIndexOf(words.filter((word) => word.trim() !== "").pop() || "");
 | 
				
			||||||
      const currentWord = words[lastNonEmptyWordIndex];
 | 
					      const currentWord = words[lastNonEmptyWordIndex];
 | 
				
			||||||
 | 
					      if (words.at(-1) === "") {
 | 
				
			||||||
 | 
					        return current_suggestions;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return current_suggestions.filter((suggestion) =>
 | 
					      return current_suggestions.filter((suggestion) =>
 | 
				
			||||||
        suggestion.toLowerCase().includes(currentWord.toLowerCase()),
 | 
					        suggestion.toLowerCase().startsWith(currentWord),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    [inputValue, suggestions, currentFilterType],
 | 
					    [inputValue, suggestions, currentFilterType],
 | 
				
			||||||
@ -636,7 +641,19 @@ export default function InputWithTags({
 | 
				
			|||||||
            inputFocused ? "visible" : "hidden",
 | 
					            inputFocused ? "visible" : "hidden",
 | 
				
			||||||
          )}
 | 
					          )}
 | 
				
			||||||
        >
 | 
					        >
 | 
				
			||||||
          {(Object.keys(filters).length > 0 || isSimilaritySearch) && (
 | 
					          {!currentFilterType && inputValue && (
 | 
				
			||||||
 | 
					            <CommandGroup heading="Search">
 | 
				
			||||||
 | 
					              <CommandItem
 | 
				
			||||||
 | 
					                className="cursor-pointer"
 | 
				
			||||||
 | 
					                onSelect={() => handleSearch(inputValue)}
 | 
				
			||||||
 | 
					              >
 | 
				
			||||||
 | 
					                <LuSearch className="mr-2 h-4 w-4" />
 | 
				
			||||||
 | 
					                Search for "{inputValue}"
 | 
				
			||||||
 | 
					              </CommandItem>
 | 
				
			||||||
 | 
					            </CommandGroup>
 | 
				
			||||||
 | 
					          )}
 | 
				
			||||||
 | 
					          {(Object.keys(filters).filter((key) => key !== "query").length > 0 ||
 | 
				
			||||||
 | 
					            isSimilaritySearch) && (
 | 
				
			||||||
            <CommandGroup heading="Active Filters">
 | 
					            <CommandGroup heading="Active Filters">
 | 
				
			||||||
              <div className="my-2 flex flex-wrap gap-2 px-2">
 | 
					              <div className="my-2 flex flex-wrap gap-2 px-2">
 | 
				
			||||||
                {isSimilaritySearch && (
 | 
					                {isSimilaritySearch && (
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user