From 5dbbc7c4d4a8289b115247ea48c611b21f331f52 Mon Sep 17 00:00:00 2001 From: anmcgrath Date: Mon, 14 Oct 2024 19:21:15 +1100 Subject: [PATCH] Fix filter not working when more than one of the same --- .../Data/Filter/ValueFilter.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/BlazorDatasheet.Core/Data/Filter/ValueFilter.cs b/src/BlazorDatasheet.Core/Data/Filter/ValueFilter.cs index 6c84bb2a..c280b8ac 100644 --- a/src/BlazorDatasheet.Core/Data/Filter/ValueFilter.cs +++ b/src/BlazorDatasheet.Core/Data/Filter/ValueFilter.cs @@ -4,7 +4,9 @@ namespace BlazorDatasheet.Core.Data.Filter; public class ValueFilter : IFilter { - private HashSet _excluded = new(); + private HashSet _excluded = new(); + + public IReadOnlyCollection Excluded => _excluded; public ValueFilter() { @@ -13,24 +15,24 @@ public ValueFilter() public void Include(CellValue value) { - _excluded.Remove(value); + _excluded.Remove(value.ToString()); IncludeAll = _excluded.Count == 0; } public void Exclude(CellValue value) { - _excluded.Add(value); + _excluded.Add(value.ToString()); IncludeAll = _excluded.Count == 0; } public bool Includes(CellValue value) { - return IncludeAll || !_excluded.Contains(value); + return IncludeAll || !_excluded.Contains(value.ToString()); } public bool Match(CellValue cellValue) { - return !_excluded.Contains(cellValue); + return !_excluded.Contains(cellValue.ToString()); } public bool IncludeBlanks { get; set; } = true; @@ -55,7 +57,8 @@ public bool IncludeAll if (value) _excluded.Clear(); - IncludeBlanks = value; + if (value) + IncludeBlanks = value; _includeAll = value; } }